Table of Contents
Installing from binary distributions is easiest, and recommended! (Why binaries? Because GHC is a Haskell compiler written in Haskell, so you've got to bootstrap it somehow. We provide machine-generated C-files-from-Haskell for this purpose, but it's really quite a pain to use them. If you must build GHC from its sources, using a binary-distributed GHC to do so is a sensible way to proceed.)
This guide is in several parts:
Installing on Unix-a-likes (Section 2.1, “Installing on Unix-a-likes”).
Installing on Windows (Section 2.2, “Installing on Windows”).
The layout of installed files (Section 2.3, “The layout of installed files”). You don't need to know this to install GHC, but it's useful if you are changing the implementation.
Most common OSes provide GHC binaries packaged using the native package format for the platform. This is likely to be by far the best way to install GHC for your platform if one of these packages is available, since dependencies will automatically be handled and the package system normally provides a way to uninstall the package at a later date.
Check the distribution packages page to see if there is a package available for your platform.
Binary distributions come in “bundles,” called
ghc-. (See the building guide for the definition of a platform.) Suppose that you untar a binary-distribution bundle, thus:
% cd /your/scratch/space % bunzip2 < ghc-
platform.tar.bz2 | tar xvf -
Then you should find the bundle contents inside a single directory,
OK, so let's assume that you have unpacked your chosen bundles. What
next? Well, you will first need to
the bundle by
changing to the bundle's top-level directory
./configure. That should convert
configure script takes a number of flags. The most
commonly used is the
flag, which tells the bundle that you want it to be installed in
/path/to/install/in rather than the default
To see all the flags that configure accepts, run
Then do the following:
make install. This
should work with ordinary Unix
make—no need for fancy stuff like GNU
If appropriate, add the bin directory to your PATH, as instructed.
You may need to run
rehash (t?csh or zsh users), in
order for your shell to see the new stuff in your bin directory.
Once done, test your “installation” as suggested in
Section 188.8.131.52, “Testing that GHC seems to be working
”. Be sure to use a
option, so you can see exactly what pathnames it's using.
If things don't work as expected, check the list of known pitfalls in
the building guide.
When installing the user-invokable binaries, this installation
procedure will install GHC as
x.xx is the version
number of GHC. It will also make a link (in the binary installation
ghc-x.xx. If you install multiple versions
of GHC then the last one “wins”, and “
ghc” will invoke the last
one installed. You can change this manually if you want. But
ghc-x.xx should always invoke GHC version
The way to do this is, of course, to compile and run this program
(in a file
main = putStr "Hello, world!\n"
Compile the program, using the
-v (verbose) flag to verify that
libraries, etc., are being found properly:
% ghc -v -o hello Main.hs
Now run it:
% ./hello Hello, world!
For more information on how to “drive” GHC, read on...