Building Mono on Leopard

In preparation of the upcoming Mono 1.2.6 release I worked through building Mono from Subversion on Leopard (i386) with Geoff Norton (kangaroo in #mono) in order to shake the rest of the bugs out of Mono on Leopard/i386. There were a couple of caveats, specifically in acquiring the necessary tools for building Mono correctly, as Leopard and the Leopard Developer Tools ship with older versions of pkgconfig(1), autoconf(1) and automake(1).

Preparing the build environment

  • First and foremost it's important to get the necessary tools installed, I suggest using MacPorts to install autoconf(1), automake(1), pkgconfig(1) and libtool(1). You'll also need Subversion to fetch the Mono sources. After installing MacPorts you can install all five in one swoop with the following command:
    sudo port install automake autoconf libtool pkgconfig subversion
  • After the aforementioned tools are installed on your machine (typically into /opt/local) you will need install a newer version of GLib onto your machine as well, as it's a key dependency of Mono. As of now the current stable version of GLib is 2.12 which you can grab from the GTK+ FTP site. Once you have downloaded GLib, you should build and install it without replacing the system GLib which could lead to problems with other applications that depend on the system version of GLib. I recommend installing it into /opt/glib which you will later tell Mono to use directly. The following steps will take care of configuring, building and installing the latest stable GLib onto your Leopard system
    • cd glib-2.12
    • ./configure --prefix=/opt/glib
    • make
    • sudo make install

Fetching and Building Mono

  • You'll need to fetch the mcs and the mono modules from Mono's anonymous Subversion repository in order to build a "distribution" of Mono (runtime and class libraries). You can grab these by running the following commands:

    • svn co svn://anonsvn.mono-project.com/source/trunk/mcs
    • svn co svn://anonsvn.mono-project.com/source/trunk/mono
  • Once you have both mcs and mono checked out, enter the mono/ directory you just checked out and configure Mono such that it uses your custom build of GLib (in /opt/glib) and installs into a custom Mono directory (/opt/mono). You will also need to modify your $PATH to make sure you use the MacPorts versions of pkgconfg(1), autoconf(1), etc.
    • export PATH=/opt/local/bin:$PATH
    • PKG_CONFIG_PATH=/opt/glib/lib/pkgconfig ./autogen.sh --prefix=/opt/mono
  • After Mono has (presumably successfully) configured itself for a build, a simple make and install will give you a fully functional Mono runtime and class library on your Leopard/i386 machine
    • make
    • sudo make install
  • Get some coffee, this could take a while

Conclusion

Now that you have Mono from Subversion built and installed on your machine, you can use it by following the steps on the Parallel Mono Environments page. Now armed with the bleeding edge version of Mono on your bleeding edge Mac OS X Leopard installation, you can check out how well your Mono applications perform on Leopard or even participate in a Mono Bug Day!

Happy Hacking.

Comments

Problem building Mono without Mono allready installed.

Thanks for the tutorial, much appreciated. I was attempting to follow these instructions under Tiger and ran into a problem while running make. I did not have an existing mono install available. I could have downloaded the current release version from the mono downloads page, but instead tried the steps outlined in the README to get the current version of the monolite distribution. Heeding the warning that this might not work, I ran the following commands to make Mono on my system:

$ make get-monolite-latest
$ make
$ sudo make install

Cool! I know have a working mono install with latest and greatest bits from svn

$ mono -V
Mono JIT compiler version 1.2.5.99 (/trunk/ r88984)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
TLS: normal
GC: Included Boehm (with typed GC)
SIGSEGV: normal
Notification: Thread + polling
Architecture: x86
Disabled: none

BTW: I added --with-preview so I can play around with some of the C# 3.0 Candy, lambda lambda lambda

- Mike

Mono for Leopard

High you geniusses,

nice to hear that someone is working on an actual version of mono for leopard.
Does anybody know when the new version will be published.
Can not wait to use it with thelastripper.....!

Greetz from germany

t.h.o.m.a.s.