Getting Started With FSharp 2.0, Mono 2.10 And Fedora
Feb 28, 2011
4 minute read

I’ve recently found F#, which is a programming language that sells itself as primarily a functional language that can also do imperative style programming and integrates with the .NET platform. This sounds like nothing but win for me, combining a lot of my favorite features in programming languages. Having recently installed Fedora 14 on a few desktops, I’ve decided to take it out for a spin.

installing mono 2.10

At the time of this writing, I could not find official RPM files for Fedora. Like Ubuntu, the repository only has old releases of the mono project (v2.6). To build it from scratch, I started off with this post by Nathan.

After using the provided script in Ubuntu, I’ve decided to run through the steps by hand in Fedora to take a look at configure options and such. The steps that I executed from a fairly new install of Fedora 14 were as follows (mostly cribbed from Nathan’s script linked to above):

1) Modify a few exports in ~/.bash_profile

export PATH=/opt/mono-2.10/bin:$PATH
export PKG_CONFIG_PATH=/opt/mono-2.10/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/opt/mono-2.10/lib:$LD_LIBRARY_PATH

and then run

source ~/.bash_profile

to get all of the new settings.

2) Make a folder to house the source tars and cd to it.

mkdir builds
mkdir builds/mono-2.10
cd builds/mono-2.10

3) Install some dependencies.

yum install -y make automake glibc-devel gcc-c++ gcc glib2-devel pkgconfig subversion bison gettext-libs autoconf httpd httpd-devel libtool wget libtiff-devel gtk2-devel atk-devel pango-devel giflib-devel libglade2-devel libexif-devel libexif libjpeg-devel git

4) Download the source packages that we’ll be building


5) Build and install libgdiplus

tar jxvf libgdiplus-2.10.tar.bz2
cd libgdiplus-2.10
./configure --prefix=/opt/mono-2.10
sudo make install

6) Install mono 2.10 itself.

tar jxvf mono-2.10.1.tar.bz2
cd mono-2.10
./configure --prefix=/opt/mono-2.10
sudo make install

7) Then install gtk-sharp.

tar jxvf gtk-sharp-2.12.10.tar.bz2
cd gtk-sharp-2.12.10
./configure --prefix=/opt/mono-2.10
sudo make install

installing F#

At this point you can get the F# 2.0 code that was released under the Apache license by using git and then compiling. “su -m” is used so that the environment variables for PATH, and LD_LIBRARY_PATH stay accessible to the root command when installing. These steps are based on Chris’s article found here.

git clone git://
cd fsharp
./configure –-prefix=/opt/mono-2.10
su -m
make install


  • The list of dependencies may not be 100% complete, but it should be close. Be aware of potentially missing *-devel packages.

  • If a “sudo make install” for F# fails because it can’t find the gacutil program, it’s probably because the root user doesn’t have modified PATH and LD_LIBRARY_PATH environment variables to find the program in /opt/mono-2.10/bin despite the user executing this command having updated variables. This is why I just did “su -m”.

  • If gtk-sharp complains about not finding csc.exe while executing ./configure, it’s because you need to set PKG_CONFIG_PATH=/opt/mono-2.10/lib/pkgconfig:$PKG_CONFIG_PATH. Once that environment variable is set, things will continue fine.

testing out F#

Now that we got the core mono and F# software installed, lets write the obligatory hello world dialog box. Put the following code into a file called test.fs.


open System
open System.Windows.Forms
open System.Drawing

type MainForm() as form =
    inherit Form()
    let label1 = new Label()
    do form.InitializeForm

    member this.InitializeForm =
        this.FormBorderStyle <- FormBorderStyle.Sizable
        this.Text <- "Hello World Application"
        this.Width <- 300
        this.Height <- 300
        label1.Text <- "Hello Internet!"
        this.Controls.AddRange([|(label1:> Control)|])

do Application.Run(new MainForm())

Without getting into details, this block of code:

1) Opens up the System.Windows.Forms library 2) Creates a new Form called MainForm 3) Constructs a basic Form and adds a Label control 4) Runs the Application by passing it a Form.

Keep in mind that spaces are significant in F# and your code should be aligned in the same manor my sample is. The F# compiler will also complain if you insert tab characters in the source code, so just stick to spaces.

If you’ve had experience with C# and .NET before, most of this will look familiar … and probably not particularly ground breaking. More on this another time!

To compile this, execute the following commands:

fsc test.fs
mono test.exe

Hello World Application.


[P.S. More of this is typed in by hand and untested than a normal post of mine because I’m short on time. Apologies in advance!]