Building Mono 2.4 from source on Ubuntu 8.10

Sad to say that the latest versions of Ubuntu and Debian do not provide the latest packages of Mono preferring stability over bleeding edge. Also, according to the packagers’  mailing list it is not an easy task to provide packages for mono and all the software that binds to it.

I am a sucker for bleeding edge, especially when it comes to thinks like Mono. The latest stable release of Mono, version 2.4 has a lot of new features like the C# interactive repl shell, SIMD extensions and better support for C# 3/.NET 3.5 features, like extension methods and LINQ. See the release notes here. I was disappointed when the most recent version of mono debian packages I could find were for the 2.0.1 version on third-party repositories.

What to do then? Download the source, configure and build to run in parallel to the version of mono installed in my Ubuntu desktop (the mono run-time is always installed on Ubuntu by default, even the live CD runs it, since it is needed to run .NET applications, like F-Spot, that have become a standard in the GNOME desktop). It turns out that it’s not that difficult as it sounds.

Step 1: Install prerequisites for compilation.

First of all, you will need to setup the appropriate tools for configuring and compiling source code. You can install these through the Synaptic package manager but for the sake of speed let’s use some command line magik Wink

Open a console and type in the following to install the gcc compiler, and development header files needed to compile the mono compilers, tools and library stack.

user@system$> sudo apt-get update
user@system$> sudo apt-get install build-essential autoconf automake \
bison flex gtk-sharp2-gapi boo gdb valac libfontconfig1-dev \
libcairo2-dev libpango1.0-dev libfreetype6-dev libexif-dev \
libjpeg62-dev libtiff4-dev libgif-dev zlib1g-dev libatk1.0-dev \
libglib2.0-dev libgtk2.0-dev libglade2-dev libart-2.0-dev \
libgnomevfs2-dev libgnome-desktop-dev libgnome2-dev libgnomecanvas2-dev \
libgnomeui-dev libgnomeprint2.2-dev libgnomeprintui2.2-dev \
libpanel-applet2-dev libnautilus-burn-dev librsvg2-dev \
libgtkhtml3.14-dev libgtksourceview2.0-dev libgtksourceview-dev \
libvte-dev libwnck-dev libnspr4-dev libnss3-dev libxul-dev \
libwebkit-dev libvala-dev

This should install all the necessary software and development headers needed for the compilation.

Step 2: Download mono 2.4 source archives.

Go to http://ftp.novell.com/pub/mono/sources-stable/ . You don’t need every archive in that list.
In this guide we will use: mono-2.4.tar.bz2libgdiplus-2.4.tar.bz2gluezilla-2.4.tar.bz2xsp-2.4.tar.bz2mono-tools-2.4.tar.bz2gecko-sharp-2.0-0.13.tar.bz2mono-debugger-2.4.tar.bz2mono-addins-0.4.zipgtk-sharp-2.12.8.tar.bz2gnome-sharp-2.20.1.tar.bz2gnome-desktop-sharp-2.20.1.tar.bz2webkit-sharp-0.2.tar.bz2

Also go to the MonoDevelop website and download the sources for monodevelop 2.0: monodevelop-2.0, monodevelop-debugger-mdb-2.0, monodevelop-debugger-gdb-2.0, monodevelop-database-2.0, monodevelop-java-2.0, monodevelop-vala-2.0

Create a directory in your home directory for the extracted sources, e.g. src/mono-2.4.

user@system$> mkdir -p src/mono-2.4; cd src/mono-2.4

Extract the downloaded archives to that directory.

Step 3: Prepare the parallel environment

Now it’s time to prepare our system for two versions of the mono runtime. A good idea is to install everything related to mono 2.2 to some path like /opt/mono-2.2 and create shell script to load an environment that will use the version located in that path instead of the default installation. That way you will not render your existing mono installation unstable or broken.

Now create a script that will load the separate mono-2.4 environment.

user@system$> cat > mono-2.4-environment
#!/bin/bash
MONO_PREFIX=/opt/mono-2.4
GNOME_PREFIX=/opt/gnome-2.4
export DYLD_LIBRARY_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include:$GNOME_PREFIX/include
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:$GNOME_PREFIX/lib/pkgconfig
PATH=$MONO_PREFIX/bin:$PATH
PS1="[mono-2.4] \w @ "

[Press Ctrl+D for EOF to write the file and get back to the prompt]

user@system$> sudo mv mono-2.4-environment /usr/local/bin
user@system$> sudo chmod +x /usr/local/bin/mono-2.4-environment

And create a second script that will load the environment and execute its argurments.

user@system$> cat > mono-2.4
#!/bin/bash
MONO_PREFIX=/opt/mono-2.4
GNOME_PREFIX=/opt/gnome-2.4
export DYLD_LIBRARY_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include:$GNOME_PREFIX/include
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:$GNOME_PREFIX/lib/pkgconfig
PATH=$MONO_PREFIX/bin:$PATH

exec "$@"

[Press Ctrl+D for EOF to write the file and get back to the prompt]

user@system$> sudo mv mono-2.4 /usr/local/bin
user@system$> sudo chmod +x /usr/local/bin/mono-2.4

Load the environment:

user@system$> source mono-2.4-environment

After this command, the prompt should change and contain [mono-2.4] to indicate that you are operating in a Mono 2.4 environment.

[mono-2.4] ~ @ cd ~/src/mono-2.4

NOTE! For the sake of readability the prompt indication in the instructions will remain the generic user@system$> but for the rest of the guide you must make sure that you follow each step while in the 2.4 environment.

And now create the directory where everything will be installed:

user@system$> sudo mkdir -p /opt/mono-2.4

Step 4: libgdiplus

Before compiling the main sources of mono we must compile libgdiplus if we want to have an implementation of the System.Drawing namespace.

user@system$> cd libgdiplus-2.4
user@system$> ./configure --prefix=/opt/mono-2.4 --with-pango

The output of the configure script should be something like this:

---
Configuration summary

   * Installation prefix = /opt/mono-2.4
   * Cairo = 1.8.0 (system)
   * Text = pango
   * EXIF tags = yes
   * Codecs supported:

      - TIFF: yes
      - JPEG: yes
      - GIF: yes
      - PNG: yes
      NOTE: if any of the above say 'no' you may install the
            corresponding development packages for them, rerun
            autogen.sh to include them in the build.

---

If any of the options say no then you have a missing dependency. You might want to use the Synaptic package manager to find the appropriate package to install. However, these dependencies are optional.

Now it’s time to build the source.

user@system$> make
user@system$> sudo make install

Step 5: mono-2.4

Now it’s time to compile mono’s main sources which will produce, among others, the c# compilers and the base class libraries.

user@system$> cd ../mono-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Verify that the mono compilers have been installed:

user@system$> which gmcs

This should output: /opt/mono-2.4/bin/gmcs
Your existing mono installation will be preserved since everything is installed to the /opt/mono-2.4 directory.

Step 6: gtk+ and gnome

Now it’s turn to compile libraries needed for desktop environment, namely gtk-sharp, gnome-sharp, gnome-desktop-sharp, gtksourceview-sharp.

user@system$> cd ../gtk-sharp-2.12.8
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../gnome-sharp-2.20.1
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../gnome-desktop-sharp-2.20.1
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 7: gluezilla, gecko-sharp, webkit-sharp

Now lets compile libraries for embedding the gecko and webkit html rendering engines.

user@system$> cd ../gluezilla-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../gecko-sharp-2.0-0.13
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../webkit-sharp-0.2
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 8: build Mono.Addins

Turn to compile the Mono.Addins libraries:

user@system$> cd ../mono-addins-0.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 9: build Mono tools

Now it’s turn to compile the marvelous collection of Mono tools, including Gendarme and GSharp (the C# interactive shell).

user@system$> cd ../mono-tools-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

After this you have installed the gsharp tool. Test it out:

user@system$> gsharp

Play a little with the C# repl Smile Type quit; when you’re done.

Step 10: build Mono XSP

This is actually something very useful. XSP is a standalone web server developed in C#. It can be run through the command line or even embedded into your application by referencing the Mono.WebServer assembly.

user@system$> cd ../xsp-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 11: build the Mono Debugger

Getting closer to the end of our compilation session, let’s build the mono debugger allowing us to debug the faulty software we write.

user@system$> cd ../mono-debugger-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 12: build MonoDevelop 2.0

Now what would all this be without a nice IDE? MonoDevelop 2.0 brings us finally debugger support!

user@system$> cd ../monodevelop-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-debugger-mdb-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-debugger-gdb-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-database-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-java-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-vala-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

And… That’s it. You now have a working mono-2.4 environment and an excellent IDE to work with.

You can launch any .NET program with Mono 2.4 with:

user@system$> mono-2.4 PATH_TO_THE_PROGRAM_AND_ITS_ARGUMENTS_IF_ANY

For example to launch MonoDevelop 2.0:

user@system#> mono-2.4 monodevelop

NOTE! This will work only for shell scripts that are normally distributed with mono applications. If you look at /opt/mono-2.4/bin/monodevelop you will see that it is a shell script that essentially runs something like this: mono /opt/mono-2.4/lib/monodevelop/bin/MonoDevelop.exe. Trying to execute a .NET application, e.g. called main.exe, by typing mono-2.4 main.exe will fail. You sould type mono-2.4 mono main.exe instead.

Enjoy hacking!

Share and enjoy Wink
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Reddit
  • Technorati
  • TwitThis

Tags: , , , , , , , ,

74 Responses to “Building Mono 2.4 from source on Ubuntu 8.10”

  1. jow says:

    Hi, I try it

    when I execute an application ubuntu says:

    / usr/local/bin/mono-2.4: line 11:. / Program_in_.net_framework.exe: Permission denied

    please, can you help me?

    thanks

    • Jan Dzik says:

      >Hi, I try it
      >
      >when I execute an application ubuntu says:
      >
      >/ usr/local/bin/mono-2.4: line 11:. / Program_in_.net_framework.exe: Permission denied

      This doesn’t sound like a problem with the mono-2.4 script that loads the environment and executes the applications. Could you provide the exact invocation of the application, including any argument?

  2. Diego Pérez says:

    Please correct in step 5

    user@system$> ./configure –prefix=/opt/mono-2.2
    to
    user@system$> ./configure –prefix=/opt/mono-2.4

    I’m on step 6 right now, but it seems to be a great guide, thanks!!!

    • Jan Dzik says:

      You are right. Fixed it. Thanks Grin

      > Please correct in step 5
      >
      > user@system$> ./configure –prefix=/opt/mono-2.2
      > to user@system$> ./configure –prefix=/opt/mono-2.4

  3. Diego Pérez says:

    Great! I finished it, simply GREAT!

  4. Peter says:

    It seems that after running through this recipe everything got installed in mono-2.2 directory. Can anyone confirm this?

    • Jan Dzik says:

      > It seems that after running through this recipe everything got installed in mono-2.2 directory. Can anyone confirm this?

      Sorry :8). FIXED it! I have more mono parallel installations, version 2.2, version 2.4 and one from trunk. All following roughly the instructions in this guide to build them. In step 2 and 5 I used the wrong directory name, mono-2.2 instead of mono-2.4. If you have everything installed to /opt/mono-2.2 a simple sudo mv /opt/mono-2.2 /opt/mono-2.4
      should suffice. In the environment scripts /usr/local/bin/mono-2.4 and /usr/local/bin/mono-2.4-environment the MONO_PREFIX variable should also point to /opt/mono-2.4 Thanks for the input Grin

  5. jow says:

    Hi!

    the exact invocation:

    user@system:~/temp/.net$ mono-2.4 ./main2.exe
    /usr/local/bin/mono-2.4: line 11: ./main2.exe: Permission denied

    the application no requires any argument.

    please, help!

    thanks a lot

    • Jan Dzik says:

      > Hi!
      > the exact invocation:
      > user@system:~/temp/.net$ mono-2.4 ./main2.exe
      > /usr/local/bin/mono-2.4: line 11: ./main2.exe: Permission denied

      Ah OK. This means that main2.exe does not have executable privilages. What happens is that the mono-2.4 script tries to execute main2.exe which is a .NET executable. This would work in windows and MS .NET. However, with Mono, .NET executables must be executed by the mono runtime (just like with java programs). This means that in order to execute your program with mono you should type: mono main.exe In Ubuntu this would be executed by the runtime that ships with the distribution. In order to use the 2.4 runtime, you should type: mono-2.4 mono main.exe This will load the 2.4 environment which switches from the default version to 2.4 (both versions use the name mono for the runtime executable) and then it will main.exe to the runtime.
      Sorry, I know it’s not a straightforward way to use the mono-2.4 script. I should have clarified on this in my post (fixing it now).

      Most mono applications however, come with shell scripts that load their *.exe (normally residing in /usr/lib/[application-name-here]) to the runtime automatically. You could do cat /usr/bin/f-spot to see that it’s a shell script that eventually does mono /usr/lib/f-spot/f-spot.exe . So if you do mono-2.4 f-spot it should try to run f-spot with mono 2-4 instead of the default version (this will fail since the 2.4 environment created does not have every .dll required by f-spot in GAC, a simple fix for this would be to add export MONO_GAC_PREFIX=”/usr:$MONO_GAC_PREFIX” to the mono-2.4 script).

  6. jow says:

    it works with mono-2.4 mono main2.exe !!!!

    thank you !!

    Smile

  7. squig says:

    Hi,

    like your tutorial, just was I was looking for Smile

    But I’m stucked at step 9, trying to compile mono-tools.
    Configuring sources quits with following message:
    checking for GTK_SHARP… configure: error: Package requirements (gtk-sharp-2.0 glade-sharp-2.0 gnome-sharp-2.0 gconf-sharp-2.0) were not met:

    No package ‘gnome-sharp-2.0′ found

    But installing gnome-sharp as described in step 6 just went fine.

    Any idea where I could have left the road?

    What about “GNOME_PREFIX=/opt/gnome-2.4″ in the shell scripts? Should I have gnome-sharp installed into /opt/gnome-2.4?

    With kind regards,

    squig

    • Jan Dzik says:

      Thanks Grin. I don’t think the problem you are facing has to do with the value of GNOME_PREFIX. gnome-sharp is a .NET library, so it is better to have it installed with the rest of the .Net libs which throughout the guide is under /opt/mono-2.4. Since the configure script cannot find gnome-sharp we should make sure if it has been installed in step 6 like it was supposed to. The configure script searches for gnome-sharp via the pkg-config system. If it was installed correctly, ls /opt/mono-2.4/lib/pkgconfig/gnome-sharp-2.0.pc should output /opt/mono-2.4/lib/pkgconfig/gnome-sharp-2.0.pc and ls /opt/mono-2.4/lib/mono/gtk-sharp-2.0/gnome-sharp.dll should output /opt/mono-2.4/lib/mono/gtk-sharp-2.0/gnome-sharp.dll. If any of the outputs is different then gnome-sharp has not been installed properly in step 6 and you should repeat it (just for gnome-sharp) making sure you use the proper prefix argument in the configure script.

      If, on the other hand, the files are there then make sure you are in the mono-2.4 environment when you try to configure/make/make install anything. If you do not see [mono-2.4] in your command prompt then you are not and should run source mono-2.4-environment . If you are in the environment then try typing echo $PKG_CONFIG_PATH . If you don’t see /opt/mono-2.4/lib/pkgconfig in the output then your environment script is wrong at which point you should repeat step 3.

      Give it a try. If it doesn’t work, post again. Hope I was helpful Smile.

      • squig says:

        Hi,

        tried to follow your hints and you are right, I’m missing gnome-sharp.dll.
        When trying to recompile it I realized that I was also missing some external dependencies, so gnome-sharp.dll was never built *ouch*

        Thanks to your advice an tutorial I now have a working environment and just started my first ASP.NET MVC app on Ubuntu Smile

        With kind regards,

        squig

  8. pO 53280,0 pO53281,0 says:

    hi Jan,

    thank you for that HowTo.

    i will give it a try.

    THX

  9. JörgenL says:

    Hi,

    I am failing in the make step of Step 8: build Mono.Addins

    ./Gendarme.Framework.Helpers/MethodSignature.cs(121,44): error CS1061: Type `Mono.Cecil.MethodReference’ does not contain a definition for `HasParameters’ and no extension method `HasParameters’ of type `Mono.Cecil.MethodReference’ could be found (are you missing a using directive or an assembly reference?)
    Compilation failed: 1 error(s), 0 warnings

    Any ideas?

    • JörgenL says:

      Sorry, that is in “Step 9: build Mono tools” of course…

      • Jan Dzik says:

        Hi! I have managed to reproduce the compilation error you have been seeing. The problem is that you have not loaded the parallel environment that mono-2.4 should run in. This means that the sources are being compiled with the mono compilers and libraries that you have normally installed in Ubuntu (which is version 1.9.1 in Intrepid Ibex). Essentially, you are compiling against older library versions.

        To fix this, you must switch to the parallel environment overriding the default mono installation, as explained in step 3. Just type in your terminal: source mono-2.4-environment . Then repeat step 9 and it should work. Try it out Grin Thnx

  10. JörgenL says:

    Hi,
    Thank you for spending time on this…

    No, that didn’t help
    Does this extrct from the output give any clues?:

    test -d ../bin || mkdir ../bin
    /usr/bin/gmcs -debug+ -d:TRACE -optimize+ -nowarn:1591 -warn:4 -warnaserror+ -target:library -doc:../bin/Gendarme.Framework.dll.doc -r:/usr/lib/mono/gac/Mono.Cecil/0.6.8.8607__0738eb9f132ed756/Mono.Cecil.dll \
    -out:../bin/Gendarme.Framework.dll ./../AssemblyStaticInfo.cs ./Gendarme.Framework.Engines/NamespaceEngine.cs ./Gendarme.Framework.Engines/OpCodeEngine.cs .
    [removed a lot of *.cs files here...]
    ./Gendarme.Framework.Rocks/FieldRocks.cs ./Gendarme.Framework.Helpers/MethodSignature.cs(121,44): error CS1061: Type `Mono.Cecil.MethodReference’ does not contain a definition for `HasParameters’ and no extension method `HasParameters’ of type `Mono.Cecil.MethodReference’ could be found (are you missing a using directive or an assembly reference?)
    Compilation failed: 1 error(s), 0 warnings
    make[3]: *** [../bin/Gendarme.Framework.dll] Error 1
    make[3]: Leaving directory `/home/jorgen/src/mono-2.4/mono-tools-2.4/gendarme/framework’
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/home/jorgen/src/mono-2.4/mono-tools-2.4/gendarme/framework’
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/jorgen/src/mono-2.4/mono-tools-2.4/gendarme’
    make: *** [all-recursive] Error 1

    • Jan Dzik says:

      Hmmm. This is the exact output that I am seeing when I don’t switch to the 2.4 environment. So my guess is that either you don’t switch to the 2.4 environment correctly or for some other reason the process fails. From the output extract you have provided, you can see on line 2 that the c# compiler used is in /usr/bin and on lines 3 – 4 you can see that the Mono.Cecil library used is in /usr/lib/mono

      Make sure that you execute source mono-2.4-environment . To verify that you are in the correct environment, the prompt has to contain [mono-2.4] and typing which gmcs should output /opt/mono-2.4/bin/gmcs . If the output is different then either your mono-2.4-environment script is wrong or some of the previous steps in the guide went wrong for you. Either case is bad and starting all over again would be the easy way out. If, on the other hand, successfully confirm that you switched to the 2.4 environment bear in mind that before typing make to compile the sources you must configure them again with ./configure --prefix=/opt/mono-2.4 .

      The correct output, in 2.4, is:
      [.............]
      make[3]: Entering directory `/home/anirothan/src/mono-2.4/mono-tools-2.4/gendarme/framework’
      test -d ../bin || mkdir ../bin
      /opt/mono-2.4/bin/gmcs -debug+ -d:TRACE -optimize+ -nowarn:1591 -warn:4 -warnaserror+ -target:library -doc:../bin/Gendarme.Framework.dll.doc -r:/opt/mono-2.4/lib/mono/gac/Mono.Cecil/0.6.9.0__0738eb9f132ed756/Mono.Cecil.dll \
      -out:../bin/Gendarme.Framework.dll ./../AssemblyStaticInfo.cs ./Gendarme.Framework.Engines/NamespaceEngine.cs ./Gendarme.Framework.Engines/OpCodeEngine.
      [.............]

      Hope this one helped Smile

  11. JörgenL says:

    Hi,

    Think I found the problem. I was copying the cat command, including all lines from the webpage and pasting it directly into terminal.

    Seems like that didnt work. It seems to work now when I took the detour over the text editor instead. Probably some issue of encoding of line endings, or whatever…

    Trying to rebuild from start now.

    Thanks for your help.

  12. JörgenL says:

    Yes, that was it. everything built smoothly this time. Thanks again.

  13. Toby Johnson says:

    Thank you so much for this guide. Even though there is nothing super-tricky here as far as building and installing the packages, it is very comforting to know that someone else has done this successfully before venturing forth on my own desktop!

    Have you ever had any problems with having multiple versions of Mono on the same desktop? I know that Windows/.NET is designed with side-by-side installs in mind but didn’t know about Linux/Mono.

    I’m VERY excited about Mono 2.4, MonoDevelop 2.0 and the newly open-sourced ASP.NET MVC framework! This could potentially be the holy grail I’ve been looking for. I gave it a try using the SuSE VmWare image but I’ll be much happier to get it running on my Ubuntu box!

    • Jan Dzik says:

      Hi! Thnx for your input Grin

      In general, linux distributions do not provide packages of different versions for side by side installations. Usually they offer updates or upgrades of the existing versions they have in their packaging systems. However, you can do this manually, like this guide explains for Mono, if, of course, you take the proper precautions not to break you existing installation. In this case it is done by installing all of the software into a separate directory hierarchy and providing scripts that setup the appropriate environmental variables to override the existing installation. This is actually the “tricky” part, along with the proper order to compile things.

      If you follow the guide, then you will not have any problem with your existing .NET applications compiled against an older version of Mono, because the installation process does not touch them.

      I share your excitement about Mono and MonoDevelop and that is why I have been following their versions by parallel installing the 2.2 version and the alpha and beta versions of MD as soon as they were released. One note though. This guide is not meant to make your vanilla Ubuntu apps like F-Spot and Tomboy to run with Mono 2.4 instead of 1.9.1. These apps run perfectly fine with 1.9.1 so there is no need to do this. It is mostly for development purposes. However, if you still want to try it out, just for the fun of it, you will need to add MONO_GAC_PREFIX env variable to the execution script. I’ve written about this some comments above.

      Happy hacking Wink

      • Toby Johnson says:

        Thanks for the reply Jan, I probably should have read the details of your guide further before asking. I like the approach you take of installing everything under /opt to make sure nothing on the parent system gets broken.

        Before I saw this post, I actually had begun work on updating the “official” Ubuntu packages with the new source so I could publish a PPA. Maybe I’ll just create one by following your instructions instead so people could install the “alternate” version under /opt without having to compile.

        I was intrigued/concerned when I began reading the changelog for the official packages which reads:
        * DFSG version of Mono 1.9.1
        + Deleted the mcs/class/System.Web.Extensions/ directory as
        mcs/class/System.Web.Extensions/System.Web.Script.Serialization/JSON/*.cs
        is licensed under Creative Commons Attribution 2.5 which is not
        DFSG-free.

        So it seems to me that the official builds will still not contain the full .NET 3.5 extensions due to licensing issues? Or will this just be available in the “multiverse” repo instead?

        I realize you may not be the one to answer these questions, but I’m still getting a bit used to the “Ubuntu/Debian way” of doing things!

        • Jan Dzik says:

          If you are going to work on a PPA for a parallel installation of the latest Mono version then I would like to proudly volunteer to help. Though I have no experience there but am eager to obtain it. You can find my contact info on the about page.

          About the licensing issue. I admit I was totally unaware of this. I think in 1.9.1 this is not included at all (I think). I really cannot say what the debian/ubuntu mono packaging team has in plan. I guess we could check the code in 2.4 to see if the license under that directory has changed but for definite answers we should ask on the packaging team’s mailing list. Of course, on a PPA a seperate package including these extensions can be provided.

          • toby johnson says:

            Well let me start off by admitting that I am completely new to PPA (and for that matter Debian packages in general)! I’ve run RedHat / CentOS servers for quite a while so I know a bit about packaging RPMs but I’m still learning the ropes of creating .deb packages. However I think that having a PPA would not only help others stay on the cutting edge, but also in general I much prefer to package anything I install myself (”sudo make install” always makes me nervous on a live system!) so it’s definitely something I’m interested in.

            I’ll probably take the rest of this week to continue reading up on the packaging tools and running practice builds and hopefully soon I’ll have something to share, so I’ll definitely let you know when I get there…

      • Toby Johnson says:

        One other question… any reason you did not compile mod_mono, or is it just something you don’t use? Any guidance on whether I should install that under /opt also, or should I install it in the regular location if I want to run it from the default Apache install?

        • Jan Dzik says:

          Yes, it is something I don’t actually use Smile I am more interested in XSP since it can be embedded. I believe that it should be installed under /opt like the rest of 2.4 or else it might overwrite the 1.9.1 mod_mono, if installed. In any case I would not install both versions on the same apache server. Parallel installation could be done by having one mod_mono and one running as FastCGI. However, these are just speculations. I haven’t really tried it. But now that you asked I am going to find some time to test and try find an optimal solution.

  14. glen worstell says:

    Thanks! A couple of issues:

    The posted copy of the shell transactions don’t show the prompt (after loading the new environment) as [mono-2.4] … , so I was not sure that all was OK.

    In step 12, 4 of the necessary files were not specified for download in step 2. Downloading and extracting in the same way as was done in step 2 allowed me to continue.

    Everything seemed to work OK, including running gsharp in step 9 (this may prove to be very useful!).

    The problem: at the end, ‘For example to launch MonoDevelop 2.0: mono-2.4 monodevelop’ does not work from either the normal environment or the 2.4 environment.

    Hints greatly appreciated!

    g.

    PS – I’d like to get rid of old mono stuff and just install 2.4 and monodevelop in the ‘normal’ places. Any hints on how to do that?

    • Jan Dzik says:

      Thank you for the input Smile
      Not changing the prompt in the instructions after executing source mono-2.4-environment in step 3 to contain [mono-2.4] was done on purpose. Including the real prompt indication in each instruction afterwards would render the instructions unreadable. I should have made that clear in step 3 but somehow I forgot. Sorry, my mistake. I edited that section in step 3 to clarify that. THNX for pointing that out Grin

      You are also right on not providing download links for monodevelop 2 sources. I fixed that too in step 2. THNX again Grin

      Any output coming from the failed execution of mono-2.4 monodevelop would be helpful. Try source mono-2.4-environment; which monodevelop. You should see /opt/mono-2.4/bin/monodevelop in the output if monodevelop was installed correctly.

      I would not suggest getting rid of “the old mono stuff”. Not entirely at least, because this guide does not include everything expected from mono in ubuntu. For example, you would not be able to run F-Spot unless you also included the GAC of 1.9.1 in the 2.4 environment. See a few comments above for more on this. You could, however, rebuild everything included in your ubuntu installation depending on mono against 2.4, but that would be a lot of work. Finally, if you are in the mood for a crazy experiment, you could repeat the steps in this guide omitting step 3 and using –prefix=/usr everywhere. This should replace the existing mono installation, most probably by braking it, don’t know, never did that.

      • toby johnson says:

        Not sure what exactly you did here but now all the backslashes are gone… they are missing from the line endings in Step 1, and from the definition of PS1 in the last line of the “mono-2.4-environment” file.

  15. Antoine Aubry says:

    This is a great tutorial. It was really helpful. I really appreciate that took the time to share this information.

    Thanks!

  16. Juan says:

    Hi, I try this instructions with svn version and I can’t use configure, instead I use (inside environment like is explained here):
    $ cd libgdiplus
    $ ./autogen.sh –prefix=/usr/local
    $ make
    $ make install

    source:
    http://mono-project.com/Compiling_Mono_From_SVN

    • Jan Dzik says:

      Yeap Smile You can follow a variation of this guide for the latest development snapshots of mono. I normally do this in /opt/mono-svn. So I use modified environment scripts that point to /opt/mono-svn and use ./autogen.sh –prefix=/opt/mono-svn instead of configure.

  17. Snail says:

    Hi,
    I got stuck on step 3 with no idea of how to proceed Grin
    I really shouldn’t be attempting something like this right? Frown
    Snail

    • Jan Dzik says:

      Hi! Step 3 is about creating two scripts (and some directories) that are essential for running two Mono installations in parallel. I guess you are stuck on creating the scripts. If you are uncomfortable with using the command line to create scripts and set permissions, you could always use a text editor like gedit and nautilus to set the permissions (right click -> properties -> permissions). Each script’s contents are the lines directly below the cat command. This guide is based entirely on work being done from the command line. However, it’s not that difficult. Give it a try.

  18. glen worstell says:

    I installed mono2.4 using the directions here: http://blog.ruski.co.za/page/Install-Mono-on-Ubuntu.aspx

    Then I installed monodevelop 2.0 and the debugger using the idea you suggested (prefix=/usr)

    It all seems to work and I am happy. Thanks for your assistance!

    g.

  19. David M says:

    Thanks for the tutorial – it’s really helpful. I think there may be a typo in the listing of the bash script mono-2.4:

    You have:
    exit `$@`

    But this gave me an error. After some trial and error I found the following worked:
    exec “$@”

    • Jan Dzik says:

      Yes you are absolutely right. It should be exec “$@” (updating the script right now). THNX. It worked with exit but did not terminate the processes properly.

  20. absolutely excellent
    very easy to follow
    best guide ive seen
    now for my next project i want to get
    mono 2.4 runtime compiled
    for my xbox
    have u got any advice for cross compiling the runtime for
    debian 4 installation running a
    hacked kernel
    linux-2.6.18-xbox

    maybe i could do it on the xbox itslef
    but it would take hours days even lol

    ive got mono-1.9.1 (from the deb reps.) on there running stuff
    already but im wanting to use Robo2SL which requires mono-2.4 to deal with some high cpu usage
    and enormous bandwidth issues

    thanx again for a great howto

    • Jan Dzik says:

      Cross compiling always is tricky business. I suggest you check the mono-dev mailing list. There are some discussions about cross compiling for ARM.

Leave a Reply