A Dreamer's Lair

Compile Mono on a Raspberry PI (for hard float support)

You could say I am a .NET man. So the first thing I investigated after deciding to develop software on the Raspberry PI for my Home Automation, was how to develop in .NET on Linux 🙂

Fortunately there is Mono. A multi platform implementation of the Microsoft .NET runtime and C# compiler. Yeah 🙂

However unfortunate, the default Raspbian distribution (I installed Debian Wheezy through the NOOBS image) still ships with the more or less ancient 2.10 version of Mono which doesn’t support the so called hard float operating systems. And guess what… the Raspberry PI uses a coprocessor so it’s hard float alright 🙁

After some searching on the internet I read that I wasn’t the only developer who wanted .NET on the Raspberry 🙂 There were some branches of the main Mono branch (in GitHub) that supported the hard float Raspberry.

I searched the internet some more to find packages which I could use to install this modified version of Mono. To no avail I must confess.

Ah well, why not compile Mono myself then? That turned out to be easier said than done. Most posts concerning making Mono were a bit too steep on my Linux learning curve. Being a Windows man myself, Linux is quite a different cup of tea where almost everything is handled in obscure command line scripts.

But after more searching, and some asking around in forums, I finally compiled together what to do build Mono on the Raspberry PI.

And for those of you, who as I struggle with the same challenge, here is what I did to build the latest Master branch of Mono (as present on Github). I performed this build on a fairly fresh Raspberry PI (with debian wheezy) so it could be that some components are already installed on your Raspberry. Well here comes.

First I needed to install some components:

sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install gettext

Also, because Mono itself is build with Mono (a bit of a paradox..) you need to have some sort of Mono compiler installed. I used monolite-fast for this. So

sudo make get-monolite-latest

Because we are building Mono from the master branch we have to clone this on the PI (to get a local version of it).

sudo git clone https://github.com/mono/mono.git

After this has been done the following command take care of initialisation and building.

cd mono
sudo git submodule init
sudo git submodule update
sudo ./autogen.sh --prefix=/usr/local
sudo make
sudo make install

After the last command has finished, and be advised that the whole build process takes a couple of hours(!) on the small Raspberry PI, the latest master branch of Mono is available on your system.

You can test the version which is now available on your system

mono --version

which should result in something like this

Mono Runtime Engine version 3.2.7 (master/bb44c68 Sat Dec  7 20:08:30 CET 2013)
Copyright (C) 2002-2013 Novell, Inc, Xamarin Inc and Contributors. <a href="http://www.mono-project.com">www.mono-project.com</a>
TLS:           __thread
SIGSEGV:       normal
Notifications: epoll
Architecture:  armel,vfp+hard
Disabled:      none
Misc:          softdebug
LLVM:          supported, not enabled.
GC:            sgen

Now we can finally develop .NET on the Raspberry!