Building Mono on Raspberry Pi

The precompiled mono version you can get in raspbian is very old (version 3.something) and we currently have version 5.2.0.179. If you want to have a more up to date version you need to compile it yourself from the source. In this post I will write the steps I have used to build it.

You can find the general mono build information here: Building mono from a release package

Prerequisites

I use raspbian jessie lite on a Raspberry Pi 3, and as always, first you should make sure your Linux is fully updated:
sudo apt-get update
sudo apt-get upgrade

Some additional packages are required:

sudo apt-get install libtool gettext cmake automake autoconf build-essential

Optional

The compile process is long so if you connect with ssh it is a good idea to use screen, so you can detach from the pi while it is compiling.

sudo apt-get install screen

to start screen simple write “screen” enter. To detach use ctrl+a d. To reattach again use “screen -r”

Get and unpack the source

Make a folder to hold the mono source:
mkdir monosrc
cd monosrc

Get the mono source:

wget http://origin-download.mono-project.com/sources/mono/mono-5.2.0.179.tar.bz2

To find the latest version number go to this web page:

http://origin-download.mono-project.com/sources/mono/

And find the latest in the list.

Unpack the file:

tar -jxf mono-5.2.0.179.tar.bz2

If you want see progress add a v to the options, it takes a few minutes to unpack the file (mostly depending of the speed of your SD-card). the progress may make it a bit slower to unpack.

Configure, Build and install

./configure --with-csc=mcs

It will take about 10 minutes to complete. Now build it:

make

This will take hours to complete (about 3 hours on raspberry pi 3, but not sure exactly because i did not sit and watch it compile!). Once the compilation is done you can install:

sudo make install

Mono is now installed and ready to use. To uninstall use:

sudo make uninstall

Verify the version

mono --version
Mono JIT compiler version 5.2.0.179 (tarball Sun 18 Jun 11:49:14 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: normal
Notifications: epoll
Architecture: armel,vfp+hard
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen (concurrent by default)

Leave a Reply

Your email address will not be published. Required fields are marked *