Installing Mono 2.4 on Ubuntu 8.10 and compiling from source

We recently had to delve into the world of .NET, which meant using Mono on Ubuntu. Ubuntu 8.10 ships with mono 1.9.x whereas we needed the most up to date version, mono version 2.4

These are the instructions on how we installed mono 2.4 and its pre-requisites on a slicehost slice running Ubuntu 8.10

Firstly get rid of the version of mono that ships with Ubuntu:

sudo apt-get remove mono-common

Now if you haven’t already, enable the multiverse and universe repositories in the sources.list (just remove the # before both lines)

sudo vi /etc/apt/sources.list

And update the sources:

sudo apt-get update

And may as well upgrade your distro while you are at it:

sudo apt-get dist-upgrade

Now install some dependencies needed for mono (if they aren’t installed already:

sudo apt-get install build-essential pkg-config libglib2.0-dev bison libcairo2-dev libungif4-dev libjpeg62-dev libtiff4-dev gettext

Now to download, configure, build and install libgdiplus:
Create a directory:

cd
mkdir dump
cd dump

Now lets get it:

wget http://ftp.novell.com/pub/mono/sources/libgdiplus/libgdiplus-2.4.tar.bz2

unzip and untar it:

tar -xvf libgdiplus-2.4.tar.bz2

and now to configure, compile and install:

cd libgdiplus-2.4/
./configure --prefix=/usr/local; make; sudo make install

This compilation takes about 5 minutes on a 512 slicehost VPS, so be prepared to wait a moment!
Now to make sure this is visible to the system:

sudo sh -c "echo /usr/local/lib >> /etc/ld.so.conf"
sudo /sbin/ldconfig

Now to download, configure, compile and install mono:

cd $HOME/dump
wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.4.tar.bz2
tar -xvf mono-2.4.tar.bz2
cd mono-2.4

There is a kernel issue in the kernel used by slicehost and ubuntu 8.10 presently with mono.
You may find if you simply comile at this point and try and use mono, you come across the following error:

ERROR:(mini-amd64.c:199):amd64_patch: assertion failed: (amd64_is_imm32 (disp))

A workaround for this presently is to add

#define MONO_ARCH_NOMAP32BIT

at the end of the file in mono/mini/mini-amd64.h, just before the very last #endif (on the last line) and then saving and compiling with this change. This worked for us!

Now lets compile and install:

./configure --prefix=/usr/local; make; sudo make install

This takes ages, probably about 20 minutes, so leave it running and come back to it in a bit!

Now

vi ~/.bashrc

And add this to your bash config (or if you use another shell you will need to add it there):

PATH=/usr/local/bin:$PATH
LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

Mono should now be installed and ready to rock, reload your shell by typing “bash” and then check to see if mono is running with “mono -V”

Now we need to install XSP. This is the mono server for Apache.

cd $HOME/dump
wget http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.4.tar.bz2
tar xvf xsp-2.4.tar.bz2
cd xsp-2.4
./configure --prefix=/usr/local; make; sudo make install

This takes a short while to compile.

Now make sure apache2 and all of the required dependencies are installed:

apt-get install apache2 apache2-threaded-dev

2 Comments

RSS feed for comments on this post. TrackBack URL

  1. george — September 2, 2009

    I’ve followed all all instructions but when I try to run my app (ie mono myapp.exe) comes up with this error:

    The assembly mscorlib.dll was not found or could not be loaded.
    It should have been installed in the `/usr/local/lib/mono/2.0/mscorlib.dll’ directory.

  2. nogeek — November 17, 2009

    Any ideas anyone?

Leave a comment

Preview: