Cross Platform F#

You can run F# on Linux and Mac thanks to the Mono Project. Mono is a cross-platform implementation of .NET runtime and core libraries. It is largely compatible with the .NET Framework (for Windows) and it can run the F# compiler as well as F# Interactive, because both of them are fully managed .NET applications. Of course, Mono can also run applications written in F# and compiled using the F# compiler.

Screencast on installing F# on Linux

I created several screencasts that guide you through the installation process on various systems and demonstrate how to use the basic command line tools as well as other cross-platform extensions for F#. You can find a complete list in the Screencasts section of this web site.

The following screencast demonstrates the first intallation option (discused below) on Linux. You’ll see how to install F# and Additional scripts and tools on Linux. We’ll also look at two examples of using F# command line tools. In the first example, we’ll use the Gtk# library from F# Interactive to create a simple user interface step by step. The second example demonstrates how to compile a Gtk# application using command line F# compiler.

Options for installing F# on Linux and Mac

There are several ways of installing F# on Linux or Mac. You can use official ZIP file from Microsoft, you can use Mac and Linux packages provided by the F# community, or you can build F# from the source drop (available under Apache 2 license).

Using official ZIP distribution

You can download the official F# distribution for Mono from the Microsoft F# Developer Center. This includes just the F# compiler and core libraries. It comes with an install shell script that instructs you how to install F#. You’ll need to re-sign the FSharp.Core.dll assembly using mono.snk key, so that it can be installed to the Global Assembly Cache (for more information see Installing F# to the GAC).

If you use this option, it is recommended to also install Additional scripts and tools from the F# cross-platform packages project. This creates convenient fsharpc and fsharpi commands, load-gtk.fsx script file (allows you to use Gtk# in F# Interactive) and it also installs additional F# assemblies to the GAC (which is required by the F# MonoDevelop plugin).

Using cross-platform packages

The F# cross-platform packages and samples project provides installer for Mac and F# packages for various Linux distributions (including portable tgz archive). You can find the packages in the Downloads section.

Currently, the RPM package does not correctly install F# assemblies to the GAC (so you may do that by hand or use the Additional scripts and tools installer to do that. You may also need to update paths in the load-gtk.fsx file (in /usr/lib/fsharp). When loading this file from F# Interactive, you’ll also need to specify the full path to the file (it is not located automatically).

Using the source code drop

F# is also available as a source drop (distributed under the Apache 2 license). You can find it in the F# PowerPack, with F# Compiler Source Drops project at CodePlex. For instructions on building F# from the source, see the readme file distributed with the source code. You should be able to install Additional scripts and tools from the F# cross-platform packages after building F# from source, but this is not currently tested. If you successfully did that, let me know, so that I can update this page!