Sitting in relative obscurity since 2007…
Quite a bit has changed since I wrote my post a few years ago on building Mono for OS X. So much has changed, in fact, that I've decided that a new post on the topic is in order. These instructions assume that you're using Snow Leopard. They should work on Leopard with minimal changes, but your mileage may vary.
Installing the prerequisites for Mono is much simpler than it once was. Previously, Mono had external dependencies like glib, which would mean you'd need to install MacPorts, but they've taken steps in the last year to reduce and eliminate such dependencies.
If you haven't yet heard about git, stop hiding under that rock! The Mono source is hosted on GitHub, so if you want to download and build it, you'll need a copy of Git. You can acquire it here.
XCode 4 is now a $4.99 download in the Mac app store. If you're too cheap for that, you can still (as of the time of this writing) grab XCode 3 here (free registration required). A copy may also be on one of the discs that came with your Mac.
While you can (theoretically) bootstrap Mono, it's not something I recommend unless you enjoy pain. Save yourself some trouble and download the latest version here.
The Mono source code is now hosted on GitHub. Open your Terminal and clone the repository by issuing the command
git clone git://github.com/mono/mono.git
First, you'll need to run autogen.sh
. Here's how I usually invoke it:
./autogen.sh --with-sgen=no --with-xen_opt=no --prefix=/opt/mono-`git rev-parse HEAD` --with-mcs-docs=no --disable-nls
My rationale for each option is listed below.
--with-sgen=no
: The Mono team considers the SGen garbage collector to be production ready, but I've had problems with it, so I still turn it off.--with-xen_opt=no
: I'm not running Xen, so there's no need for this.--prefix=/opt/mono-`git rev-parse HEAD`
: You may want to just use --prefix=/opt/mono
. I include the git revision in the path to make it easier to keep a number of parallel installations around for testing purposes.--with-mcs-docs=no
: The documentation takes a while to build and generally won't be much different than what's in your installed copy of Mono. Save yourself some time and leave it out.--disable-nls
: I don't need this particular feature. If you do, leave it in.Assuming that autogen.sh
completes successfully, you can now build it with
make -j1
Depending upon how your development environment is set up, you may not need the -j1
. However, if your default MAKEFLAGS
has a different -j
option, you'll want to use this. Otherwise, the Mono build can fail in strange ways. Once this is done, run sudo make install
, and you'll be all set!