Getting F# running on Linux

Getting F# running on Linux took a lot more effort than I anticipated. I am documenting the process here in the hope it may benefit someone (maybe myself) in the future. For reference, I am using OpenSuse 13.1.

  • F# is not compatible with all versions of Mono. For example, my distro repos have Mono 3.0.6 which appears to have some issues with F#. Instead, I found some people make new Mono packages available for various distros using Opensuse Build Service (OBS). For example, check out tpokorra repos for various distros such as OpenSUSE, CentOS,  Debian etc. I installed “mono-opt” and related packages. It installed mono 3.4 into /opt/mono directory.
  • If you install mono into /opt/mono, then ensure that you do append “/opt/mono/lib” into the LD_LIBRARY_PATH environment variable and /opt/mono/bin to the PATH variable. I did this in my .bashrc.
  • By default, /opt/mono/bin/mono turned out to be a symlink to /opt/mono/bin/mono-sgen. Now it appears that Mono has two versions: one using sgen GC and one using Boehm GC. I have had trouble with compilng F# using mono-sgen so I removed /opt/mono/bin/mono and then created it as a symlink to /opt/mono/bin/mono-boehm.
  • Now open up a new shell. In this shell, set up a few environment variables temporarily required for building F#. First, “export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig”. Next, we need to setup some GC parameters for Mono. It turns out compiling F# requires a lot of memory and Mono craps out with default GC parameters. I have a lot of memory in my laptop, so I set the Mono GC to use upto 2GB as follows: “export MONO_GC_PARAMS=max-heap-params=2G”. These two settings likely won’t be required after you have compiled and installed F#.
  • Now you can follow the instructions given on the F# webpage.

Specifically I did

  • git clone https://github.com/fsharp/fsharp
  • cd fsharp
  • ./autogen –prefix /opt/mono  #Keep things consistent with rest of mono install
  • make  #Takes a lot of time
  • su
  • make install
Email this to someonePrint this pageShare on Google+Share on RedditTweet about this on TwitterShare on LinkedIn

2 thoughts on “Getting F# running on Linux”

Leave a Reply

Your email address will not be published. Required fields are marked *