久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

ubuntu如何編譯安裝mono環(huán)境

共計(jì) 9683 個(gè)字符,預(yù)計(jì)需要花費(fèi) 25 分鐘才能閱讀完成。

今天丸趣 TV 小編給大家分享一下 ubuntu 如何編譯安裝 mono 環(huán)境的相關(guān)知識(shí)點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識(shí),所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來(lái)了解一下吧。

準(zhǔn)備工作

先在 vs2012 上編譯一個(gè) winform,代碼如下:

using system;
using system.windows.forms;
namespace formstest
static class program
///  summary 
///  應(yīng)用程序的主入口點(diǎn)。///  /summary 
[stathread]
static void main()
application.enablevisualstyles();
application.setcompatibletextrenderingdefault(false);
application.run(new form());
}

嘗試在 ubuntu 上用 mono 運(yùn)行:

nike@nike-pc:~$ cd desktop/
nike@nike-pc:~/desktop$ ls
formstest.exe
nike@nike-pc:~/desktop$ mono formstest.exe
unhandled exception:
system.typeinitializationexception: an exception was thrown by the type initializer for system.windows.forms.xplatui ---  system.typeinitializationexception: an exception was thrown by the type initializer for system.drawing.gdiplus ---  system.dllnotfoundexception: /opt/mono-3.2.8/lib/libgdiplus.so
at (wrapper managed-to-native) system.drawing.gdiplus:gdiplusstartup (ulong ,system.drawing.gdiplusstartupinput ,system.drawing.gdiplusstartupoutput)
at system.drawing.gdiplus..cctor () [0x00000] in  filename unknown :0
--- end of inner exception stack trace ---
at system.drawing.graphics.fromhdcinternal (intptr hdc) [0x00000] in  filename unknown :0
at system.windows.forms.xplatuix11.setdisplay (intptr display_handle) [0x00000] in  filename unknown :0
at system.windows.forms.xplatuix11..ctor () [0x00000] in  filename unknown :0
at system.windows.forms.xplatuix11.getinstance () [0x00000] in  filename unknown :0
at system.windows.forms.xplatui..cctor () [0x00000] in  filename unknown :0
--- end of inner exception stack trace ---
at system.windows.forms.application.enablevisualstyles () [0x00000] in  filename unknown :0
at formstest.program.main () [0x00000] in  filename unknown :0
[error] fatal unhandled exception: system.typeinitializationexception: an exception was thrown by the type initializer for system.windows.forms.xplatui ---  system.typeinitializationexception: an exception was thrown by the type initializer for system.drawing.gdiplus ---  system.dllnotfoundexception: /opt/mono-3.2.8/lib/libgdiplus.so
at (wrapper managed-to-native) system.drawing.gdiplus:gdiplusstartup (ulong ,system.drawing.gdiplusstartupinput ,system.drawing.gdiplusstartupoutput)
at system.drawing.gdiplus..cctor () [0x00000] in  filename unknown :0
--- end of inner exception stack trace ---
at system.drawing.graphics.fromhdcinternal (intptr hdc) [0x00000] in  filename unknown :0
at system.windows.forms.xplatuix11.setdisplay (intptr display_handle) [0x00000] in  filename unknown :0
at system.windows.forms.xplatuix11..ctor () [0x00000] in  filename unknown :0
at system.windows.forms.xplatuix11.getinstance () [0x00000] in  filename unknown :0
at system.windows.forms.xplatui..cctor () [0x00000] in  filename unknown :0
--- end of inner exception stack trace ---
at system.windows.forms.application.enablevisualstyles () [0x00000] in  filename unknown :0
at formstest.program.main () [0x00000] in  filename unknown :0

遇到錯(cuò)誤了 system.dllnotfoundexception: /opt/mono-3.2.8/lib/libgdiplus.so,原因是如果要在 ubuntu 運(yùn)行 winform,那么必須要安裝 libgdiplus。

下載 libgdiplus 并編譯

nike@nike-pc:~$ cd src
nike@nike-pc:~/src$ wget http://download.mono-project.com/sources/libgdiplus/libgdiplus-2.10.9.tar.bz2
--2014-03-27 22:46:40-- http://download.mono-project.com/sources/libgdiplus/libgdiplus-2.10.9.tar.bz2
resolving download.mono-project.com (download.mono-project.com)... 54.230.157.116, 54.230.157.204, 54.230.158.216, ...
connecting to download.mono-project.com (download.mono-project.com)|54.230.157.116|:80... connected.
http request sent, awaiting response... 200 ok
length: 2074317 (2.0m) [application/x-bzip2]
saving to: ‘libgdiplus-2.10.9.tar.bz2 
 
100%[======================================] 2,074,317 224kb/s in 9.5s
 
2014-03-27 22:46:54 (213 kb/s) - ‘libgdiplus-2.10.9.tar.bz2  saved [2074317/2074317]
 
nike@nike-pc:~/src$ ls
libgdiplus-2.10.9.tar.bz2 mono-3.2.8 mono-3.2.8.tar.bz2
nike@nike-pc:~/src$ tar -xvjf libgdiplus-2.10.9.tar.bz2
nike@nike-pc:~/src$ cd libgdiplus-2.10.9/
nike@nike-pc:~/src/libgdiplus-2.10.9$ ./configure --prefix=/opt/mono-3.2.8
============== 省略了很多 ==============
checking pkg-config is at least version 0.9.0... yes
checking for base_dependencies... no
configure: error: package requirements (glib-2.0  = 2.2.3) were not met:
no package  glib-2.0  found
consider adjusting the pkg_config_path environment variable if you
installed software in a non-standard prefix.
 
alternatively, you may set the environment variables base_dependencies_cflags
and base_dependencies_libs to avoid the need to call pkg-config.
see the pkg-config man page for more details.

遇到錯(cuò)誤了,需要安裝 libglib2.0-dev:

nike@nike-pc:~/src/libgdiplus-2.10.9$ sudo apt-get install libglib2.0-dev
reading package lists... done
building dependency tree
reading state information... done
the following extra packages will be installed:
libglib2.0-0 libglib2.0-bin libpcre3-dev libpcrecpp0 zlib1g-dev
suggested packages:
libglib2.0-doc
the following new packages will be installed:
libglib2.0-dev libpcre3-dev libpcrecpp0 zlib1g-dev
the following packages will be upgraded:
libglib2.0-0 libglib2.0-bin
2 upgraded, 4 newly installed, 0 to remove and 273 not upgraded.
need to get 2,728 kb of archives.
after this operation, 9,208 kb of additional disk space will be used.
do you want to continue [y/n]?
============== 省略了很多 ==============

重新初始化 libgdiplus 安裝配置文件:

nike@nike-pc:~/src/libgdiplus-2.10.9$ ./configure --prefix=/opt/mono-3.2.8
============== 省略了很多 ==============
checking for libpng14... checking for libpng12... no
checking for png_read_info in -lpng... no
configure: error: *** libpng12 not found. see http://www.libpng.org/pub/png/libpng.html.

又遇到錯(cuò)誤了,需要安裝 libpng-dev:

nike@nike-pc:~/src/libgdiplus-2.10.9$ sudo apt-get install libpng-dev

重新初始化 libgdiplus 安裝配置文件:

nike@nike-pc:~/src/libgdiplus-2.10.9$ ./configure --prefix=/opt/mono-3.2.8
============== 省略了很多 ==============
./configure: line 13371: test: too many arguments
configure: error:  failed to compile with x11/xlib.h include. you must fix your compiler paths

提示錯(cuò)誤,需要安裝 libx11-dev:

nike@nike-pc:~/src/libgdiplus-2.10.9$ sudo apt-get install libx11-dev

重新初始化 libgdiplus 安裝配置文件:

nike@nike-pc:~/src/libgdiplus-2.10.9$ ./configure --prefix=/opt/mono-3.2.8
============== 省略了很多 ==============
configure: error: cairo requires at least one font backend.
please install freetype and fontconfig, then try again:
http://freetype.org/ http://fontconfig.org/
configure: error: ./configure failed for cairo

需要安裝 freetype 和 fontconfig:

nike@nike-pc:~/src/libgdiplus-2.10.9$ sudo apt-get install libfreetype6-dev
nike@nike-pc:~/src/libgdiplus-2.10.9$ sudo apt-get install fontconfig
nike@nike-pc:~/src/libgdiplus-2.10.9$ sudo apt-get install libfontconfig1-dev

重新初始化 libgdiplus 安裝配置文件:

nike@nike-pc:~/src/libgdiplus-2.10.9$ ./configure --prefix=/opt/mono-3.2.8
============== 省略了很多 ==============
configuration summary
 
* installation prefix = /opt/mono-3.2.8
* cairo = 1.6.4 (internal)
* text = cairo
* exif tags = no. get it from http://libexif.sourceforge.net/
* codecs supported:
 
- tiff: no (get it from http://www.libtiff.org/)
- jpeg: no (get it from http://freshmeat.net/projects/libjpeg)
- gif: no (see http://sourceforge.net/projects/libgif)
- png: yes
 
note: if any of the above say  no  you may install the
corresponding development packages for them, rerun
autogen.sh to include them in the build.
nike@nike-pc:

./configure 通過(guò)。

編譯安裝源代碼

nike@nike-pc:~/src/libgdiplus-2.10.9$ make
make all-recursive
make[1]: entering directory `/home/nike/src/libgdiplus-2.10.9 
making all in pixman
make[2]: entering directory `/home/nike/src/libgdiplus-2.10.9/pixman 
make all-recursive
make[3]: entering directory `/home/nike/src/libgdiplus-2.10.9/pixman 
making all in pixman
make[4]: entering directory `/home/nike/src/libgdiplus-2.10.9/pixman/pixman 
/bin/bash ../libtool --tag=cc --mode=compile gcc -dhave_config_h -i. -i.. -g -o2 -wall -fvisibility=hidden -mt pixman-access.lo -md -mp -mf .deps/pixman-access.tpo -c -o pixman-access.lo pixman-access.c
../libtool: line 852: x--tag=cc: command not found

遇到錯(cuò)誤了,通過(guò) google 搜索,可能是因?yàn)樵陧?xiàng)目目錄下生成的 libtool 腳本中定義了 $echo 變量,但是在腳本文件 ltmain.sh 中,使用的卻是 $echo(生成的 libtool 版本太舊)解決方法很簡(jiǎn)單 export echo=echo 即可:

nike@nike-pc:~/src/libgdiplus-2.10.9$ export echo=echo
nike@nike-pc:~/src/libgdiplus-2.10.9$ make
============== 省略了很多 ==============
make[2]: entering directory `/home/nike/src/libgdiplus-2.10.9/tests 
/bin/bash ../libtool --tag=cc --mode=link gcc -g -o2 -pthread -o testgdi testgdi.o ../src/libgdiplus.la -lpthread -lfontconfig
libtool: link: gcc -g -o2 -pthread -o .libs/testgdi testgdi.o ../src/.libs/libgdiplus.so -lpthread -lfontconfig -pthread -wl,-rpath -wl,/opt/mono-3.2.8/lib
/usr/bin/ld: testgdi.o: undefined reference to symbol  g_print 
/lib/i386-linux-gnu/libglib-2.0.so.0: error adding symbols: dso missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [testgdi] error 1
make[2]: leaving directory `/home/nike/src/libgdiplus-2.10.9/tests 
make[1]: *** [all-recursive] error 1
make[1]: leaving directory `/home/nike/src/libgdiplus-2.10.9 
make: *** [all] error 2

編譯時(shí)又出錯(cuò)了,解決辦法為:1. 運(yùn)行./configure 后,編輯 tests/makefile 文件 2. 在 makefile 文件 130 行位置,將 libs = -lpthread -lfontconfig 改為 libs = -lpthread -lfontconfig -lglib-2.0 -lx11 3. 再次運(yùn)行 make 即可

nike@nike-pc:~/src/libgdiplus-2.10.9$ vim tests/makefile
nike@nike-pc:~/src/libgdiplus-2.10.9$ make
============== 編譯很快 ==============
nike@nike-pc:~/src/libgdiplus-2.10.9$ sudo make install
============== 省略了很多 ==============

安裝完成。

設(shè)置 path 環(huán)境變量

nike@nike-pc:~/src/mono-3.2.8$ cd ~
nike@nike-pc:~$ vim .bashrc

在該文件末尾追加以下語(yǔ)句:export ld_library_path=/opt/mono-3.2.8/lib 然后:

nike@nike-pc:~$ . .bashrc
nike@nike-pc:~$ echo $ld_library_path
/opt/mono-3.2.8/lib
nike@nike-pc:~$

驗(yàn)證 libgdiplus 是否安裝成功

nike@nike-pc:~$ cd desktop/
nike@nike-pc:~/desktop$ mono formstest.exe

運(yùn)行成功。

以上就是“ubuntu 如何編譯安裝 mono 環(huán)境”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,丸趣 TV 小編每天都會(huì)為大家更新不同的知識(shí),如果還想學(xué)習(xí)更多的知識(shí),請(qǐng)關(guān)注丸趣 TV 行業(yè)資訊頻道。

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-17發(fā)表,共計(jì)9683字。
轉(zhuǎn)載說(shuō)明:除特殊說(shuō)明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請(qǐng)注明出處。
評(píng)論(沒有評(píng)論)
主站蜘蛛池模板: 睢宁县| 梁平县| 苗栗县| 莒南县| 陆丰市| 福海县| 吴江市| 广水市| 萨迦县| 鄄城县| 彭阳县| 随州市| 荆门市| 洛隆县| 兴业县| 五大连池市| 吉林市| 梅州市| 鱼台县| 义乌市| 石门县| 洛浦县| 江孜县| 腾冲县| 团风县| 万安县| 平陆县| 辽宁省| 日土县| 白山市| 潮州市| 乐都县| 来安县| 红原县| 新竹市| 绥棱县| 兴和县| 长治县| 巫山县| 荣成市| 五指山市|