Building Mono from scratch

What you will need

I am assuming for this that your machine has never seen a copy of mono in it's life and that you have on your machine a copy of gcc, gtkhtml3-devel (contains all of the libraries and headers for gtkhtml3) and the linux toolchain (automake, autoconf, make etc)

You can quickly test to see if you have any of these...

gcc --help
Usage: gcc [options] file...
Options:
  -pass-exit-codes         Exit with highest error code from a phase
  --help                   Display this information
  --target-help            Display target specific command line options
rpm -q gtkhtml3-devel automake autoconf make
gtkhtml3-devel-3.3.2-3
make-3.80-5
automake-1.9.3-1
autoconf-2.59-5
mcs
bash: mcs: command not found

If you haven't one of the bits required installed, either download them via yum (or apt-get) and install them. I would recommend using the precompiled versions, really as it gives you a solid base to work from!

Next, get hold of a copy of monocharge-latest. You can do this by downloading from the go-mono website or by using wget

wget http://www.go-mono.com/daily/monocharge-latest.tar.gz
(you will then see the file download and will be told when it's down)

Next, you need to dearchive the tarball and install it. IMPORTANT When you install monocharge, you can decided if you want to accept the default install position (/usr/local/) or to define your own. When you compile mono, it is important that you remember where you have installed monocharge to.

tar -zxf monocharge-latest.tar.gz
cd monocharge-20041124 (the number is the date, it changes daily!)

If you want to accept the defaults, type

su
./recharge.sh
exit

If you want to change the install place (say, /usr)

su
env prefix=/usr ./recharge.sh
exit

During the install, you may get errors, don't worry about them, you're only after the binaries being installed rather than anything else.

Getting mono, mcs and other modules

All of the source files required are held in an svn repository which is easily accessed. You can do it by hand or by using this script. The svn repository has a large number of modules for compilation, but to get started, download mono, mcs, libgdiplus and gtk-sharp

svn co svn://mono.myrealbox.com/source/trunk/<module name>

Replace "module name" with mono, mcs, libgdiplus and gtk-sharp in turn. If you use the script, edit it so that only these 4 modules are in the first part.

The script will also download cairo, libpixman and monodevelop which are required later.

Move into the mono directory (cd ~/mono). If you've accepted the monocharge default, type ./autogen.sh otherwise type ./autogen.sh --prefix=/usr (from my example). This will run the setup script and create the configuration files.

The next step is to type make. This will compile mono and mcs in one step. Once the compilation is complete, su and then make install. Mono and mcs are now installed on your machine.

A quick test

Type the following in as a quick and simple test to see if everything is fine

using System;

class HelloWorld
{
  static void Main(string [] args)
  {
     Console.Writeline("Hello, I'm mono");
  }
}

Save as hello.cs

mcs hello.cs
mono hello.exe
Hello, I'm mono

Mono is now happy.

Compiling libgdiplus and gtk-sharp

libgdiplus does not require mono to be installed. If you have installed mono to anywhere other than the default, include --prefix=/usr after the ./autogen.sh

cd ~/libgdiplus
./autogen.sh
make
su
make install
exit
cd ../gtk-sharp
./autogen.sh

Once the gtk-sharp configuration script has been created, it will tell you what will be built. It is important here that it says gtkhtml-sharp: yes - it is required for monodoc. If it is not there, then you don't have gtkhtml3-devel which is new enough installed and you will need to get hold of a copy from somewhere

make
su
make install
exit

Well done! You now have the basics of a fully working system. It's not complete but is better than nothing!

Compiling everything else

Some of the extras can be a pain to compile and install and this page is getting a bit long, so to continue, you'll need to progress to another page