Haskell Platform from Source on Unix-Like

Albert Y. C. Lai, trebla [at] vex [dot] net

Why you may like to build Haskell Platform from source: there is no binary package for your OS; there are binary packages for your OS but you don't like them (versions, directories, privileges). (If you have none of those problems, good for you!)

This article is for Unix-like OSes, generalizing from what works on Ubuntu Linux.

Required C Libraries and Headers

Haskell Platform and GHC rely on some C libraries. You need them and their headers present to build Haskell Platform. As a partial test of presense, look for the following files in /usr/include, /usr/lib, /usr/local/include, /usr/local/lib, etc.

namea.k.a.a fileremarks
libgmp3c2libgmp.so.3GHC website binary still wants libgmp.so.3
GLUTfreeglut3-devGL/glut.halso OpenGL, X... too many to list but your package manager likely gets them all from GLUT

Planning Ahead: Choose Where to Install

By default, Haskell Platform files will be scattered over various places in /usr/local. Same story for GHC if you install it yourself.

You may dislike this for one of two reasons. When you want to delete files, they are harder to hunt down. If you want several versions of Haskell Platform or GHC to co-exist, they step over each other in /usr/local/bin (Haskell Platform contains executables too).

How I do it: I create one directory (say /usr/local/haskell-platform-2012.4.0.0) and put one GHC and one Haskell Platform inside. I adjust my PATH environment variable accordingly (add /usr/local/haskell-platform-2012.4.0.0/bin). Switching versions means just editing PATH. You could further separate GHC and Haskell Platform into two directories if you want.


You must install GHC yourself to build Haskell Platform from source. While binary packages of Haskell Platform include GHC, the source does not. Any means of installing GHC is fine:

There is a matching version of GHC for each version of Haskell Platform, and it is seldom the “current released” version. Normally you should stick to the matching version of GHC; the benefits are that the matched pair has been well-tested together and is well-supported. Using a slightly older or newer GHC is possible but slightly more risky.

Haskell Platform versionGHC version

Build Haskell Platform

Look for “Build from source” and get the .tar.gz file on “Haskell Platform for Linux”.

Unpack and change directory into the unpacked.

Configure with:

./configure --prefix=chosen-directory

If you lack some C libs or headers, it tells you now.

If you use a mismatched GHC, it also finds out now, and you can insist with

./configure --prefix=chosen-directory --enable-unsupported-ghc-version

If there is no problem so far, you can build now, and it will take 5-10 minutes:


If it builds successfully, you can install now, and this needs enough privilege:

make install

When it finishes, it instructs you to initialize “the package list” with the following command. What it means: download the list of packages available on Hackage, store it under $HOME/.cabal/packages/hackage.haskell.org.

cabal update

After it finishes, sometimes it suggests:

Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install

Please don't be an enslaved human and obey your computer lord mechanically. This is an informative notice, not a normative order. There is always a catch. (Think: if there were no catch, why would they await your confirmation? Consider who gets the liability.)

The catch: sometimes installing new versions of cabal-install require installing second instances of libraries. Possessing multiple instances of libraries can be confusing, see my article Storage and Identification of Cabalized Packages. See below for preventing multiple instances of libraries.

Rectify Wrong Settings

The command cabal update you ran also initializes a configuration file $HOME/.cabal/config. Take some time to review it. In particular there are some wrong defaults.

-- library-profiling: False
-- documentation: False

One default says that libraries you install later will not support profiling. Another default says that libraries you install later will not have documentation built. These are the exact opposite of what a programmer needs. Uncomment them and fix them:

library-profiling: True
documentation: True

Lastly, possessing multiple instances of a library can be confusing, see my article Storage and Identification of Cabalized Packages. Unfortunately, the default behaviour of cabal install is promiscuous and silent in adding multiple instances. Fortunately, since Haskell Platform version 2012.2.0.0, there is a mechanism to prevent this.

Add these lines at a suitable place in the file, such as near the line “-- constraint:”:

(Haskell Platform version shown. Showing another version requires javascript.)

The idea is to add one line for each package that comes with GHC or Haskell Platform. You may also add lines for other packages—but only after you install them! Do not add a line for a package you don't already have.

I have more Haskell Notes and Examples