Appendix A. Installing GHC

Table of Contents

Windows
Mac OS X
Ubuntu and Debian Linux
Fedora Linux

We are providing the instructions below based on our experience installing GHC in mid-2007. Installation instructions inevitably become dated quickly; please bear this in mind as you read.

We will update these instructions for GHC 6.8.2 when time permits.

Because GHC runs on a large number of platforms, we've focused on a handful of the most popular.

Windows

The prebuilt binary packages of GHC should work on versions of Windows as old as ME, and on all newer versions (NT, 2000, XP, and Vista). We have installed GHC 6.6.1 under Windows XP Service Pack 2; here are the steps we followed.

[Note]How much room does GHC need?

On Windows, GHC requires almost 340MB of disk space.

Our first step is to visit the GHC download page, and follow the link to the current stable release. Scroll down to the section entitled “Binary packages”, and then again to the subsection for Windows. Download the installer; in our case, it's named ghc-6.6.1-i386-windows.exe.

After the installer has downloaded, double-clicking on it starts the installation process. This involves stepping through a normal Windows installer wizard.

Once the installer has finished, the Start Menu's “All Programs” submenu should have a GHC folder, inside of which you'll find an icon that you can use to run ghci.

Clicking on the ghci icon brings up a normal Windows console window, running ghci.

[Note]Updating your search path

The GHC installer automatically modifies your user account's PATH environment variable so that commands like ghc will be present in the command shell's search path (i.e. you can type a GHC command name without typing its complete path). This change will not take effect until you log out and back in again.

Mac OS X

Installing GHC on Mac OS X takes several steps, as GHC does not yet have a standard OS X installer. We have installed GHC 6.6.1 under Mac OS X 10.4, on an Intel-based MacBook. We're not regular Mac users, and had never tried installing GHC on OS X before, and everything worked for us on the first try, so take heart if these instructions seem daunting. The process is neither difficult nor especially time-consuming.

Our first step is to visit the GHC download page, and follow the link to the current stable release. Scroll down to the section entitled “Binary packages”, and then again to the subsection for Mac OS X. There are four components to download, all of which are necessary.

  • Apple's Xcode development software. This provides compiler toolchain support that GHC needs.

  • The GNUreadline framework provides flexible command line editing.

  • The GMP framework is required for arbitrary-precision integer support.

  • The GHC package itself. This will not work unless both of the preceding frameworks are installed.

The Xcode software installer may have come bundled on a DVD with your Mac. If not (or you can't find it), you can download it from Apple and install it. Once you've finished installing Xcode, continue on to download the remaining three packages.

After these downloads complete, you'll have three archive icons on your desktop.

Double click on each one to unpack it, giving you three folders.

Open a Finder window with command+n. In the left sidebar, click on your system's main hard disk icon (often named “Macintosh HD”). In the main portion of the window, double click on System to open that folder, then on Library. Select the GMP.framework and GNUreadline.framework folders on your desktop, and drag them onto the Frameworks folder in the Finder window that is visiting /System/Library. If the Finder refuses to install them because you don't have permission, it will probably display an “Authenticate” button in the alert it displays. Click it, enter your password, and installation can proceed.

With the prerequisites in place, you can turn to installing GHC. You'll need to open a Terminal window (you can find it in /Applications/Utilities).

[Tip]Terminal at your fingertips yet?

Since most of your interactions with GHC will be through a Terminal window, this might be a good time to add the Terminal application to your dock, if you haven't already done so.

Inside the Terminal window, change directory to Desktop/ghc-6.6.1, and run ./configure to set up the command line installer. This configures GHC to install to /usr/local. When the configure script finishes, run sudo make install, and type your password when you are prompted for it.

The installation process should take a minute or two. If you don't already have /usr/local/bin in your shell's search path, add it.

Finally, you should be able to successfully run the ghci command from your shell prompt.

Ubuntu and Debian Linux

FIXME: actual content.

Fedora Linux

GHC is available as a standard Fedora binary package. From a shell, all you need to do is run sudo yum -y install ghc ghc-doc ghc661-prof. The base package, containing the ghc and ghci commands and libraries, is ghc. The ghc-doc package contains the GHC user guide, and command and library documentation. The ghc661-prof package contains profiling-capable versions of the standard libraries (note: its version number may have changed by the time you read this).

Once installation has finished, you should be able to run ghci from the shell immediately. You won't need to change your shell's search path, or set any environment variables.

Want to stay up to date? Subscribe to the comment feed for this chapter, or the entire book.

Copyright 2007 Bryan O'Sullivan, Don Stewart, and John Goerzen. This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 License. Icons by Paul Davey aka Mattahan.