This is an updated guide on how to compile mono from source on Ubuntu. This time, it’s about Ubuntu 14.04 (trusty tahr). This post covers:

  • mono
  • xsp
  • libgdiplus
  • nuget
  • nant
  • mod_mono
  • gtksharp


  • For simplicity, I’ve ommitted the ‘sudo’ from the parts where it is needed.
  • The source code is going to be checked out under /usr/local/src.
  • Installation is going to be made in /usr/local.


These are the basic requirements for a build environment. Remember that apt-get install is supposed to be run as root.

apt-get install git build-essential pkg-config autoconf automake libtool gettext

We’ll be checking out the code in /usr/local/src, so lets go and create that directory:

mkdir /usr/local/src

After everything is installed you can delete it to save some disk space. Personally I keep it around in case I want to fetch the latest code again from upstream and rebuild.


First, mono itself:

cd /usr/local/src
git clone git://
cd mono
./ --prefix=/usr/local
make get-monolite-latest
make install


XSP is a web server:

cd /usr/local/src
git clone git://
cd xsp
./ --prefix=/usr/local
make install


libgdiplus is needed for drawing and stuff:

cd /usr/local/src
git clone
cd libgdiplus
git checkout 2.10.8

It has some extra prerequisites:

apt-get install libglib2.0-dev libjpeg-dev libtiff5-dev libpng12-dev libgif-dev libexif-dev libx11-dev libxrender-dev libfreetype6-dev libfontconfig1-dev

Now this is going to be tricky. On Ubuntu 14.04, it no longer builds without some editing of the source code. There are just two files to edit:

  • src/gdiplus-private.h
  • tests/

First, edit src/gdiplus-private.h. Instead of including the filefreetype/tttables.h, you need to include ft2build.h and FT_TRUETYPE_TABLES_H. This is shown in the following diff:

ngeor@mini:/usr/local/src/libgdiplus$ git diff src
diff --git a/src/gdiplus-private.h b/src/gdiplus-private.h
index 59edf9e..283280d 100644
--- a/src/gdiplus-private.h
+++ b/src/gdiplus-private.h
@@ -30,7 +30,9 @@
 #include <stdio.h>
 #include <math.h>
 #include <glib.h>
-#include <freetype/tttables.h>
+#include <ft2build.h>

Then, edit the second file that is causing problems, tests/ You need to add a LIBS dependency, as shown in the following diff:

diff --git a/tests/ b/tests/
index 5b8c67c..b07da64 100644
--- a/tests/
+++ b/tests/
@@ -1,4 +1,5 @@
 ## for libgdiplus/tests


This should be enough to make libgdiplus compile with the usual incantation:

./ --prefix=/usr/local
make install

nuget certificates

For every user that is going to be using NuGet, you need to import some certificates with:

mozroots --import --sync

This needs to be run only once but it should be run for every user that needs nuget. That’s also the user that is running your continuous integration builds.


And now, nuget itself. Why not create a script so that nuget can be easily accessible from the command line?

First, download nuget.exe and copy it to /usr/local/bin/. Then, create the following script:

exec mono $MONO_OPTIONS $(dirname $0)/nuget.exe $*

and save it as /usr/local/bin/nuget. Don’t forget to grant it execute permissions.


I always have some problems when it comes to nant. Usually something goes wrong with pkg-config or sometimes it defaults to using .NET 2.0. I tried two approaches here. The first one was to download the latest tarball and try to install it. The second one was to get the latest source and build it. I believe that the second option is better in the end. Here are both of them:

first option: use the latest tarball

Download the latest tarball and extract it into /usr/local/lib. So

Create a shell script named nant and place it in /usr/local/bin:

exec mono $MONO_OPTIONS /usr/local/lib/nant-0.92/bin/NAnt.exe $*

you might need to invoke it with MONO_OPTIONS=--runtime=v4.0

You’ll probably need to modify NAnt.exe.config too.

  • set mono-4.5 the default ``` ``` </li>
  • add mono-4.5 definition based on 4.0 ``` Unable to locate 'mono' module using pkg-config. Download the Mono development packages from true mcs true linq true true true true true true true mjs strict vbnc true true true sn true false true ```
  • </ul>

    second option: build from source

    The following commands might be just enough to install nant: ``` git clone cd nant make install MONO='mono --runtime=v4.0' prefix=/usr/local/ TARGET=mono-4.0 ``` Notice the extra parameters trying to convince nant it should use .NET 4.

    apache2 mod_mono

    If you want to host ASP.NET websites with Apache, you can use mod_mono. Prerequisites: ``` apt-get install apache2-dev ``` Installation: ``` git clone cd mod_mono ./ --prefix=/usr/local --with-mono-prefix=/usr/local make make install ``` Note that the module configuration is installed in /etc/apache2/mod_mono.conf. However, the a2enmod utility is looking for module configurations in the directory /etc/apache2/mods-available. If you want to use a2enmod, you should link mod_mono.conf inside the expected directory. Or, you can just include the module configuration inside your site configuration as needed. For example: ``` <VirtualHost *:80> ServerName DocumentRoot /var/www/ Include mod_mono.conf </VirtualHost> ```


    gtksharp is currently building against gtk3. If you need gtk2 support, you can checkout the latest tag that supports gtk2 and build that. You can also build both of them and install them side by side.


    First the prerequisites: ``` apt-get install libgtk-3-dev ``` And then the usual build: ``` git clone cd gtk-sharp ./ --prefix=/usr/local make make install ```


    Prerequisites: ``` apt-get install libgtk2.0-dev libpango1.0-dev libglade2-dev ``` And the build (notice we’re building the tag 2.12.22): ``` git clone gtk-sharp-2 cd gtk-sharp-2 git checkout 2.12.22 ./bootstrap-2.12 --prefix=/usr/local make make install ```

    This one goes pretty fast: ``` git clone cd mono-basic ./configure --prefix=/usr/local make make install ```


    The above will give you mono (latest and greatest!) and more or less anything related to it. One thing that is missing is monodevelop, the IDE. Perhaps I’ll cover that in a future post, together with the programming language boo.