Compiling Mono
From Mono
| Table of contents |
|
1 Building Mono from the Subversion Repository |
Overview
This document describes how to compile and install Mono from its source code, the source code is available from our download page. If you are only interested in running Mono, you might want to install Mono from packages, which have been tested.
Mono core:
- libgdiplus-x.y.z.tar.gz
- mono-x.y.z.tar.gz package
ASP.NET hosting:
- xsp-x.y.z.tar.gz
- mod_mono-x.y.z.tar.gz
Gtk# and GUI tools:
- gtk-sharp-x.y.z.tar.gz
- monodoc-x.y.z.tar.gz
Cocoa#:
- cocoa-sharp-x.y.z.tar.gz
Compiling manually
You will need to obtain the Mono dependencies first: glib 2.x (http://www.gtk.org) and pkg-config (http://www.freedesktop.org/software/pkgconfig).
Building From Packages
This applies to both the officially released packages, as well as the daily tarball packages (http://www.go-mono.com/daily/).
Unpack the Mono runtime distribution:
tar xzvf mono-X.XX.tar.gz; cd mono-X.XX
Then configure, compile and install:
./configure --prefix=/usr/local; make; make install
This will give you a runtime, C# compiler and runtime libraries, where /usr/local is the prefix where Mono will be installed. You can change this to suit your needs.
Building Mono from the Subversion Repository
The Mono source code is available to Mono developers and also for enthusiasts through anonymous SVN.
Notice that the build procedure changed between Mono 1.0.xx and Mono 1.1.xx, so users are encouraged to use the Mono 1.1.xx or newer branch.
To upgrade your Mono installation from SVN, it is very important that you update your Mono and MCS modules from SVN at the same time. Failure to do so might result in a problematic installation as the runtime and the class libraries will be out of sync.
Building Mono 1.1.xx or newer from SVN
For full details about checking out your source code, see: SVN Write Access and the Anonymous SVN access pages).
Checking out for the first time
If you are checking out Mono from SVN for the first time, you can use anonymous access:
$ svn co svn://anonsvn.mono-project.com/source/trunk/mono $ svn co svn://anonsvn.mono-project.com/source/trunk/mcs $ svn co svn://anonsvn.mono-project.com/source/trunk/libgdiplus
If you have an account on the main Subversion repository, use the following command:
$ svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/mcs $ svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/mono $ svn co svn+ssh://USER@mono-cvs.ximian.com/source/trunk/libgdiplus
Updating an existing checkout
$ (cd mono; svn update) $ (cd mcs; svn update) $ (cd libgdiplus; svn update)
Building the source
Then, go into the mono directory, and configure:
$ cd mono $ ./autogen.sh --prefix=/usr/local $ make $ make install
By running autogen.sh from the mono tree, it will automatically go into the mcs/ tree and build the binaries there, so you don't have to run it in both mono and mcs trees.
This assumes that you have a working mono installation, and that there's a C# compiler named 'mcs', and a corresponding IL runtime called 'mono'.
In order to use mcs and mono binaries during the build process which do not reside in your PATH, you can set two make variables, EXTERNAL_MCS and EXTERNAL_RUNTIME:
make EXTERNAL_MCS=/foo/bar/mcs EXTERNAL_RUNTIME=/somewhere/else/mono
If you do not currently have mono installed, try building the get-monolite-latest target first:
make get-monolite-latest
make EXTERNAL_MCS=false
The file mono/README (http://anonsvn.mono-project.com/viewcvs/trunk/mono/README?rev=82972&view=auto) contains more information about ways to compile Mono from the repository, consult it if you need more details.
Also to get the latest changes in System.Drawing.dll and System.Windows.Forms.dll you also need configure, build and install libgdiplus.
$ cd libgdiplus $ ./autogen.sh --prefix=/usr/local $ make $ make install
If you use a different prefix then you may need to adjust your LD_LIBRARY_PATH environment variable to ensure libgdiplus.so can be loaded.
export LD_LIBRARY_PATH=/your/own/prefix:$LD_LIBRARY_PATH
Building Mono 1.0.xx from SVN
Mono 1.0 has been deprecated.
Checking out for the first time
If you are checking out Mono 1.0.x from SVN for the first time, use the following command:
$ svn co svn+ssh://USER@mono-cvs.ximian.com/source/branches/mono-1-0
If you do not have an account on the main Subversion repository, you can use anonymous access:
$ svn co svn://anonsvn.mono-project.com/source/branches/mono-1-0
Updating an existing checkout
$ (cd mono-1-0; svn update)
Compiling your Mono 1.0.x from SVN
Then you can run:
(cd mono-1-0/mono; make bootstrap)
Now you can install the result:
(cd mono; make install)
Notice that following the above procedure does not require you to manually install the software in the `mcs' directory, as the relevant files will be copied by the `mono' makefiles.
Windows Compilation
Update: a tutorial on building Mono on Windows by Andreia Gaita is available here (http://shana.iidbbs.com/en/mono_cygwin_tutorial.html).
There are two ways of building Mono on Windows, both do require a Cygwin setup which provides some tools required by Mono at build time. First, download and install Cygwin from www.cygwin.com.
Make sure you select the following packages when installing:
* autoconf * automake * bison * gcc-mingw-core * gcc-mingw-g++ * libtool * make * python
A proper make version (v3.80, recent Cygwin version are broken) is available from here (http://www.go-mono.com/archive/helper/make-3.80-1.tar.bz2).
Select some handy utils for later use:
* unzip (needed for the relocation script below) * wget * zip
Some other tools that are nice:
* cvs * patch * openssh or PuTTY * subversion, alternatively TortoiseSVN * vim
At this point, you can do a VisualStudio build or you can continue reading the instructions for a cygwin build.
Now it's time to get some other dependencies:
* ftp://ftp.gtk.org/pub/gtk/v2.6/win32/glib-2.6.6.zip * ftp://ftp.gtk.org/pub/gtk/v2.6/win32/glib-dev-2.6.6.zip * http://www.gimp.org/~tml/gimp/win32/pkgconfig-0.15.zip * http://www.gimp.org/~tml/gimp/win32/libiconv-1.9.1.bin.woe32.zip * http://www.gimp.org/~tml/gimp/win32/gettext-0.14.5.zip * http://www.gimp.org/~tml/gimp/win32/gettext-dev-0.14.5.zip
Do some path relocation on these dependencies with this script:
do-install-zip-pkgs (http://anonsvn.mono-project.com/viewcvs/*checkout*/trunk/release/packaging/do-install-zip-pkgs)
Note: utils.py (http://anonsvn.mono-project.com/viewcvs/*checkout*/trunk/release/pyutils/utils.py) needs to be in the same dir as do-install-zip-pkgs
Call it like this from within Cygwin's bash:
./do-install-zip-pkg <dest> <dest> <path_to_zip_files>/*.zip
Example:
./do-install-zip-pkg /tmp/build_deps /tmp/build_deps /tmp/*.zip
This will extract the zip files to /tmp/build_deps and change the pkg-config .pc files to use /tmp/build_deps as well as set up a script called env.sh that will set up some environment variables
Note: this script also does relocation for other things not necessarily needed in the above zip files, but it should work fine for our purposes here. If you want to change the .pc files manually, that's also fine. Just make sure you set up your environment as well (PATH and PKG_CONFIG_PATH).
If you used the script, load the environment:
. /tmp/build_deps/env.sh
Download the Mono source code from the released tarballs (http://go-mono.com/sources) or Anonymous SVN.
If you download the tarball, extract it with:
tar -zxvf mono-x.x.x.x.tar.gz
Add mono to your path. This could be either a previous build of Mono, or an install from the Mono Windows Combined Installer from Downloads. Using the installer is probably the easiest for most cases.
export PATH=$PATH:<path to installed mono>/bin
In the mono source directory, run the following:
./configure --prefix=/tmp/install
Feel free to use any prefix you like. Continue with:
make make install
If everything goes well, you will have a compiled mono in an hour or two.
Note: There are several ways to get the glib dependencies. For example, they come with the Mono Combined Installer. The above details and instructions are shown in order to demonstrate how the Mono Combined Installer is built.
Building GTK#
Building GTK# 2 uses a similar process as building Mono. First, we'll need some more dependencies:
* Microsoft's .NET Framework and SDK from msdn.microsoft.com/downloads.
The MS .NET SDK is needed because the gtk-sharp2 build currently uses the disassembler and assembler from the MS SDK for a portion of the build. Eventually, the gtk-sharp2 build will use the tools from Mono, but currently this is how it's done.
Now the Gtk dependencies:
* ftp://ftp.gtk.org/pub/gtk/v2.6/win32/gtk+-2.6.9.zip * ftp://ftp.gtk.org/pub/gtk/v2.6/win32/gtk+-dev-2.6.9.zip * ftp://ftp.gtk.org/pub/gtk/v2.6/win32/atk-1.9.0.zip * ftp://ftp.gtk.org/pub/gtk/v2.6/win32/atk-dev-1.9.0.zip * ftp://ftp.gtk.org/pub/gtk/v2.6/win32/pango-1.8.2.zip * ftp://ftp.gtk.org/pub/gtk/v2.6/win32/pango-dev-1.8.2.zip * http://primates.ximian.com/~wberrier/windows-installer/win32_deps/libxml2-2.6.20-mono.win32.zip * http://www.gimp.org/~tml/gimp/win32/libart_lgpl-2.3.14.zip * http://www.gimp.org/~tml/gimp/win32/libart_lgpl-dev-2.3.14.zip * http://www.gimp.org/~tml/gimp/win32/librsvg-2.4.0.zip * http://www.gimp.org/~tml/gimp/win32/librsvg-dev-2.4.0.zip * http://www.gimp.org/~tml/gimp/win32/libgsf-1.8.2-20040121.zip * http://www.gimp.org/~tml/gimp/win32/libgsf-dev-1.8.2.zip * http://easynews.dl.sourceforge.net/sourceforge/gladewin32/libglade-2.4.0-dev.zip * http://easynews.dl.sourceforge.net/sourceforge/gladewin32/libglade-2.4.0-bin.zip
Place these zip files in the same directory as the above zip files and run the do-install-zip-pkgs script again.
If you haven't loaded the env.sh file in this bash session, do that now.
Make sure that Mono is not in the path, and put the MS tools in the path. Here's an example of how to do this from the cygwin bash shell:
CSC=`cygpath -d /cygdrive/c/WINDOWS/Microsoft.NET/Framework/v1.1.4322` CSC=`cygpath -a $CSC`
SDK=`cygpath -d "/cygdrive/c/Program Files/Microsoft.NET/SDK/v1.1/Bin"` SDK=`cygpath -a $SDK` export PATH=$SDK:$CSC:$PATH
Now we can start building. Unpack the gtk-sharp2 source and enter it's directory. Here are the commands to build:
export CC="gcc -mno-cygwin" # Make sure we're not dependent on cygwin sed -i "s/2.3.16/2.3.14/" configure # Fudge a version requirement ./configure --prefix=/tmp/install # Choose any prefix you like sed -i "s/\/cyg\//\/\//" libtool # Remove cyg from dll names
make make install
mv /tmp/install/lib/*.dll /tmp/install/bin # Move dll files as a windows convention
Again, choose any prefix in place of /tmp/install .
This build is much shorter than the Mono build. The .NET dll's will be place in the MS GAC. Enjoy!
Other useful links:
- Microsoft's .NET Framework SDK from msdn.microsoft.com/downloads. This can be useful for testing.
- Kevin Shockey's very complete step by step article (http://www.ondotnet.com/pub/a/dotnet/2005/02/07/monowindows.html) on building Mono on Windows.
- Up to date glib (http://anonsvn.mono-project.com/viewcvs/*checkout*/trunk/release/packaging/defs/mono) and gtk (http://anonsvn.mono-project.com/viewcvs/*checkout*/trunk/release/packaging/defs/gtk-sharp) dependencies that are being used for the Mono Windows Combined Installer.
Advanced Features
So far we have described how to build a default Mono installation, the one that will get all the default features configured based on your operating system. It is possible to tune your Mono configuration to your particular needs by using configure-time options.
A complete list of options are shown if you run the configure script with the --help option, but here we describe some important elements.
Supported Features
These are configuration options that the Mono team does provide support for.
Xen Support
If you are planning on running Mono on Xen instances, you should use the --with-xen_opt=yes flag.
This will make Mono use a Xen-friendly set of TLS operations.
This is a supported configuration option.
Prefix
There are a number of options that control where Mono will install its files.
Usually Mono is rooted on a "prefix", and binaries, libraries, data files, manual pages are then based from this prefix. To customize the prefix, you pass the --prefix command line option to configure.
Unsupported Features
Most users will use the default configuration, and the Mono team will provide help and support for the standard configuration. Any use of extra configuration options is likely going to have little or no support from the team.
The documentation in the following sections merely documents these features as they have been known to be useful to people.
Minimal Mono
It is possible to build a Mono virtual machine that has fewer features than a full installation. This allows Mono to be shipped in 2-3 megabytes of disk space and consume less memory, but it will also limit the funcionality available. To do this use the --enable-minimal parameter, this parameter takes a comma separated list of features that you want removed, like this:
./configure --enable-minimal=aot
That would remove the ahead of time compilation feature.
The following features can be removed:
- aot ahead of time compilation.
- profiler: profiler support.
- decimal: support for the System.Decimal (decimal type) in Mono.
- pinvoke: Platform Invoke services to call into native libraries
- debug: debugging support (line number information, debuggability of applications.
- reflection_emit: generating code with the System.Reflection.Emit API
- logging: a handful of routines used for debugging the JIT.
- com: Support for COM Interop.
- ssa: the SSA-family of optimizations.
- generics: support for the 2.0 generics in the runtime.
Alternative Stack during Overflows
By default Mono will detect whether your operating system/architecture supports an alternate stack when a stack overflow happens. If supported, Mono will run a small piece of code that will trigger a StackOverflowException in your program instead of aborting your application with a Segmentation Fault.
You can overwrite the auto detection by using the --enable-sigaltstack flag.
We only support this feature if it is auto-detected, not if you manually forced it.
Static vs Dynamic Mono
The Mono compilation will produce a binary to run your ECMA CLI applications (mono) and a library that can be used to embed the Mono runtime in other applications (libmono).
Compilers generate slower code when they produce shared libraries, so by default the Mono build system will create the "mono" binary with a static copy of the libraries and will not use its own libmono shared library.
You can change this feature by using the --with-static_mono option, but we discourage this practice as static Mono is faster and static Mono is also the most commonly tested configuration.
Thread Local Storage Specification
Use the --with-tls option to specify the kind of thread local storage that Mono should use. The possible values are __thread (which uses the compiler supported attribute for TLS) or pthread (which uses the POSIX API for storing thread-local data).
This configuration option is automatically detectd at configure time, and we only support this option if its auto-detected, if you force this option, you are on your own.
Controlling the Profile to Build
By default Mono will build 1.0 and 2.0 libraries and compilers, you can turn off the compilation of 2.0 features by using the --with-preview=no flag.
Turning 2.0 off is not a supported configuration.
Individual Prefix Configuation
Mono also allows different components to be installed into other places other than the prefix-rooted installation. These are not supported by the Mono team, but might be useful:
You can further control various data files by using one or more of the following options:
--bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man]

Powered by MediaWiki