个人工具

UbuntuHelp:MonoFromSource

来自Ubuntu中文

Wikibot讨论 | 贡献2007年12月6日 (四) 10:43的版本

跳转至: 导航, 搜索

Compiling Mono From Source

Due to the current lag between Mono releases and Ubuntu/Debian packages being available, this page will help you to compile the latest release of Mono from source. These instructions are for use with Ubuntu 5.04 (Hoary Hedgehog), Ubuntu 5.10 forwards already has a more recent version of Mono in the repositories.

Pre-Requisites

Since we're going to be compiling code, we need to satisfy some requirements before we begin. We also need to satisfy some dependencies for Mono.

bash:~$ sudo apt-get install build-essential pkg-config libglib2.0-dev bison libcairo1-dev

Now we're going to need somewhere to work:

bash:~$ mkdir src
bash:~$ cd src

libgdiplus

Optional - Although the following are not required, they do provide more functionality to libgdiplus.

bash:~/src/$ sudo apt-get install libungif4-dev libjpeg62-dev libtiff4-dev

Let's grab the tarball:

bash:~/src/$ wget http://www.go-mono.com/sources/libgdiplus-1.1/libgdiplus-1.1.9.tar.gz

...and extract it:

bash:~/src/$ tar xzf libgdiplus-1.1.9.tar.gz
bash:~/src/$ cd libgdiplus-1.1.9

Now we can compile and install it:

bash:~/src/libgdiplus-1.1.9/$ ./configure --prefix=/usr/local
bash:~/src/libgdiplus-1.1.9/$ make
bash:~/src/libgdiplus-1.1.9/$ sudo make install

Now we have to make sure the installed libraries are visible - there are several ways to do this, this is just one.

bash:~/src/libgdiplus-1.1.9/$ sudo sh -c "echo /usr/local/lib >> /etc/ld.so.conf"
bash:~/src/libgdiplus-1.1.9/$ sudo /sbin/ldconfig

Now we can leave this folder...

bash:-~/src/libgdiplus-1.1.9/$ cd ..

...and move onto the next step.

Mono

Compiling Mono itself is pleasantly straightforward:

bash:~/src/$ wget http://www.go-mono.com/sources/mono-1.1/mono-1.1.9.tar.gz
bash:~/src/$ tar xzf mono-1.1.9.tar.gz
bash:~/src/$ cd mono-1.1.9
bash:~/src/mono-1.1.9/$ ./configure --prefix=/usr/local --with-preview=yes
bash:~/src/mono-1.1.9/$ make
bash:~/src/mono-1.1.9/$ sudo make install
bash:~/src/$ cd ..

You can check the install as follows:

bash:~/src/$ mono -V
Mono JIT compiler version 1.1.9, (C) 2002-2005 Novell, Inc and Contributors. www.mono-project.com
        TLS:           normal
        GC:            Included Boehm (with typed GC)
        SIGSEGV      : normal
        Globalization: normal

Gtk#

There are two variants of Gtk# - 1.x and 2.x. Different applications may require one or the other, and due to the nature of Mono there is no harm in having both. Both depend on various GNOME/GTK+ development libraries, which can be satisified as follows:

bash:~/src/$ sudo apt-get install libgnome-desktop-dev libgtkhtml3.2-dev

There are also optional dependencies, which - if you require them - can be satisified with:

bash:~/src/$ sudo apt-get install libgnomedb2-dev librsvg2-dev libvte-dev

As with Mono itself once you've satisfied the dependencies, compilation is straight forward.

1.x

bash:~/src/$ wget http://go-mono.com/sources/gtk-sharp/gtk-sharp-1.0.10.tar.gz
bash:~/src/$ tar xzf gtk-sharp-1.0.10.tar.gz
bash:~/src/$ cd gtk-sharp-1.0.10
bash:~/src/gtk-sharp-1.0.10/$ ./configure --prefix=/usr/local
bash:~/src/gtk-sharp-1.0.10/$ make
bash:~/src/gtk-sharp-1.0.10/$ sudo make install
bash:~/src/$ cd ..

You can test your install with the following:

bash:~/src/$ sudo ldconfig
bash:~/src/$ mono gtk-sharp-1.0.10/sample/GtkDemo/GtkDemo.exe

2.x

Gtk# 2.x has an additional dependency:

bash:~/src/$ sudo apt-get install libpanel-applet2-dev
bash:~/src/$ wget http://go-mono.com/sources/gtk-sharp-2.0/gtk-sharp-2.3.91.tar.gz
bash:~/src/$ tar xzf gtk-sharp-2.3.91.tar.gz
bash:~/src/$ cd gtk-sharp-2.3.91
bash:~/src/gtk-sharp-2.3.91/$ ./configure --prefix=/usr/local
bash:~/src/gtk-sharp-2.3.91/$ make
bash:~/src/gtk-sharp-2.3.91/$ sudo make install
bash:~/src/$ cd ..

You can test your install with the following:

bash:~/src/$ sudo ldconfig
bash:~/src/$ mono gtk-sharp-2.3.91/sample/GtkDemo/GtkDemo.exe

Conclusion

You've now got a fully functioning Mono/Gtk# environment, and you can move onto compiling/developing your own applications!