Tuesday, March 18, 2008


Installing Mono with yum

Creators of Mono so far haven't made it very simple to install; precompiled binaries exist only for few not the most popular distributions like Red Hat Enterprise 4 or OpenSuSe 10.3. But even there, it is a bit of a pain to download, verify dependencies and install all required packages.

One tool suggested to help somewhat with with problem is yum. Today we will talk about what it takes to use yam on Red Hat Enterprise 4 to install latest Mono release.

Note that at any point during that process it may turn out that your system is missing some requirements which mine didn't; it is assumed you know to to locate missing packages on whatever media you are using and install them.

We begin by installing certain prerequisites of yum. All of them are python packages, and all of them should be compatible with python 2.3.4 which comes with RHE4; upgrading to a newer python version may be possible, but not recommended since yum also depends on python package rpm, which is part of RedHat distribution.

  1. urlgrabber. cd /tmp
    wget http://linux.duke.edu/projects/urlgrabber/download/urlgrabber-3.1.0.tar.gz
    tar -xvzf urlgrabber-3.1.0.tar.gz
    cd urlgrabber-3.1.0
    python setup.py build
    python setup.py install
  2. ElementTree. Using http://effbot.org/media/downloads/elementtree-1.2-20040618.tar.gz, same procedure as above;
  3. cElementTree.
    Using http://effbot.org/media/downloads/cElementTree-1.0.5-20051216.tar.gz, same procedure as above.
Now we are ready to install yum. I used version 2.6.1, since according to this, it is the latest version compatible with python 2.3.X.
cd /tmp
wget http://linux.duke.edu/projects/yum/download/2.6/yum-2.6.1.tar.gz
tar -xvzf yum-2.6.1.tar.gz
cd yum-2.6.1
make DESTDIR=/
make DESTDIR=/ install
Make sure yum module loads properly, and fix problems if there are any :
[root@myRHE4 ~]# python
Python 2.3.4 (#1, Jan  9 2007, 16:40:18)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
Create info about mono repository:
cd /etc/yum.repos.d
wget http://www.go-mono.com/download-stable/rhel-4-i386/mono.repo
You're ready to begin installation! Here is what I installed:
yum install mono-complete
yum install gtk-sharp2-complete
yum install mono-basic
yum install mono-debugger
One last item - optional, but nice - it is to make sure Linux kernel can run your Mono applications "natively" (like Windows), without using "mono" every time. Following these directions, create script like that:
#! /bin/bash
if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
    /sbin/modprobe binfmt_misc
    # Some distributions, like Fedora Core, perform
    # the following command automatically when the
    # binfmt_misc module is loaded into the kernel.
    # Thus, it is possible that the following line
    # is not needed at all. Look at /etc/modprobe.conf
    # to check whether this is applicable or not.
    mount -t binfmt_misc none /proc/sys/fs/binfmt_misc

# Register support for .NET CLR binaries
if [ -e /proc/sys/fs/binfmt_misc/register ]; then
    # Replace /usr/bin/mono with the correct pathname to
    # the Mono CLR runtime (usually /usr/local/bin/mono
    # when compiling from sources or CVS).
    echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register
    echo "No binfmt_misc support"
    exit 1
and run it as root (or append to file /etc/rc.local as suggested) To verify your installation, use program "Hello, World!" from here :
using Gtk;
using System;

class Hello {

static void Main()
Application.Init ();

// Set up a button object.
Button btn = new Button ("Hello World");
// when this button is clicked, it'll run hello()
btn.Clicked += new EventHandler (hello);

Window window = new Window ("helloworld");
// when this window is deleted, it'll run delete_event()
window.DeleteEvent += delete_event;
// Add the button to the window and display everything
window.Add (btn);
window.ShowAll ();

Application.Run ();

// runs when the user deletes the window using the "close
// window" widget in the window frame.
static void delete_event (object obj, DeleteEventArgs args)
Application.Quit ();

// runs when the button is clicked.
static void hello (object obj, EventArgs args)
Console.WriteLine("Hello World");
Application.Quit ();
To compile and run:
gmcs helloworld.cs -pkg:gtk-sharp-2.0

Labels: , , ,

Hey Kostya -- This is very helpful, thanks! I am running into a problem, though: when I try to run "yum install mono-complete," the install fails with the error message:
Error: Missing Dependency: glib2-devel is needed by package mono-devel
Error: Missing Dependency: libungif.so.4 is needed by package libgdiplus0
Error: Missing Dependency: libexif.so.9 is needed by package libgdiplus0
Error: Missing Dependency: libtiff.so.3 is needed by package libgdiplus0

I've just installed Glib 2.20, but the error has stayed the same. Does this mean I'm stuck with compiling mono myself, or is there somethign easier I can do to get the .repo file working...? Thanks very much for any light you can shed.
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?