Installing F# 2.0 on Mono/Linux

Yes, you can program F# on Linux. Thanks to the Mono project supported by Novell, the F# SDK provided by Microsoft can be run on Linux using the Mono CLR on Linux. You need to perform the following steps on your Linux installation:

1. Install the Mono development packages provided by your Linux distribution. After installing test your mono installation in the shell as follows

~> mono -V
Mono JIT compiler version 2.6.4 (tarball Mon Jul  5 13:23:55 UTC 2010)
Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com
 TLS:           __thread
 GC:            Included Boehm (with typed GC and Parallel Mark)
 SIGSEGV:       altstack
 Notifications: epoll
 Architecture:  x86
 Disabled:      none

2. Download the F# SDK from the Microsoft website into your home directory

http://www.microsoft.com/download/en/details.aspx?id=11100

3. Install the F# package and run the installation script

~> su
Password:
~ # cd /usr/local/lib
/usr/local/lib # unzip ~/fsharp.zip
...
/usr/local/lib # cd FSharp-2.0.0.0
/usr/local/lib/FSharp-2.0.0.0 # wget http://anonsvn.mono-project.com/source/trunk/mcs/class/mono.snk
...
/usr/local/lib/FSharp-2.0.0.0 # bash install-mono.sh
-- Resigning FSharp.Core.dll with mono.snk
Assembly bin/FSharp.Core.dll signed.
-- Installing FSharp DLLS into the GAC
Installed bin/FSharp.Core.dll into the gac (/usr/lib/mono/gac)

4. Create the shell scripts fsc and fsi to launch the F# compiler and the interactive easily

~# cat /usr/local/bin/fsc
#!/bin/bash
/usr/bin/mono /usr/local/lib/FSharp-2.0.0.0/bin/fsc.exe $@

~# cat /usr/local/bin/fsi
#!/bin/bash
/usr/bin/mono /usr/local/lib/FSharp-2.0.0.0/bin/fsi.exe $@

5. Test your installation

~> fsc
Microsoft (R) F# 2.0 Compiler build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

error FS0207: No inputs specified

~> fsi

Microsoft (R) F# 2.0 Interactive build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> #quit;;

- Exit...
~>
About these ads
This entry was posted in Installation. Bookmark the permalink.

2 Responses to Installing F# 2.0 on Mono/Linux

  1. 2sharp4u says:

    I just recently discovered that Scala is using ‘fsc’ for ‘fast scala compiler’, therefore, you may want to name the shell command for the F# compiler and interactive differently. I suggest to name them ‘fsc.exe’ and ‘fsi.exe’

  2. 2sharp4u says:

    If you encounter the following type of error in the interactive it may be due to an incompatibility issue between F# and Mono 2.8.
    > type a = A | B;;
    error FS0193: Operation is not supported.

    This error is fixed in the F# Community Technology Preview April 2011 which may be downloaded from the following link:
    http://www.microsoft.com/download/en/details.aspx?id=11100
    You need to uninstall your F# installation (rm -Rf /usr/local/lib/FSharp-2.0.0.0) and reinstall according the above procedure.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s