Building mono from source

From LSDevLinux
Revision as of 17:45, 28 January 2013 by Mayhewn (talk | contribs) (Build and install custom mono: Move PATH change out of loop)

Jump to: navigation, search


On Ubuntu or Debian Linux

$ sudo apt-get install bison mono-devel libgif-dev libjpeg-dev libtiff4-dev libexif-dev git quilt

And of course to build the package you'll also need:

$ sudo apt-get install devscripts cdbs

On Mac

$ sudo port install bison mono giflib git-core quilt

Note: port is the MacPorts package management command. For further information, see Build FieldWorks for Mac.

Build and install custom mono

To build the custom mono, paste in the following commands:

export PATH=/usr/lib/ccache:$MONO_PREFIX:$PATH

cd ~/fwrepo/mono && 
for repo in libgdiplus mono mono-basic gtk-sharp; do
  cd $repo

  if [ $repo = "gtk-sharp" ]; then

  [ -e configure ] || NOCONFIGURE=1 $AUTOGEN_CMD
  ./configure --prefix=$MONO_PREFIX
  sudo make install

  cd "$OLDPWD"

The installation will prompt for your sudo password to install into /usr/local.

To ensure the use of the custom version of mono in /usr/local when you run applications, make sure /usr/local/bin is in your PATH before /usr/bin is, or (better) use /usr/local/bin/mono application.exe whenever you run an application. On most Linux distros, /usr/local/bin is already included in your PATH. You can check to see what your current PATH is by typing:

$ echo $PATH

Note that the Linux binfmt system that allows you to execute interpreted programs without specifying the interpreter on the command line (eg by typing just application.exe) will still use /usr/bin/mono unless you reconfigure it.

If you want to develop additional changes to mono, after the initial set-up, you can use make and make install in the appropriate subdirectory to apply them.

Register in GAC

Since you are installing mono into /usr/local, you will need to register some /usr/lib/mono assemblies into the /usr/local/lib/mono GAC.

$ for assembly in /usr/lib/mono/gac/{glib,pango,atk,gtk,gdk}-sharp/*/*-sharp.dll; \
    do sudo gacutil -i $assembly; done

Trying to do this step in Precise gave me errors and did not register anything. An example error is:

Failure adding assembly /usr/lib/mono/gac/glib-sharp/*/*-sharp.dll to the cache: The system cannot find the file specified.

Update custom mono

To get the latest custom mono:

$ cd ~/fwrepo/mono && for repo in libgdiplus mono mono-basic gtk-sharp; do
 cd $repo && git pull && ./configure --prefix=/usr/local && make && 
 sudo make install && cd -; done