2.2. Installing on Windows

Getting the Glasgow Haskell Compiler (GHC) to run on Windows platforms can be a bit of a trying experience. It should be much easier now than in the past, since all the software required to build and use GHC is included in the InstallShield.

An installation of GHC requires about 70M of disk space (which can be reduced by choosing a “compact” installation). To run GHC comfortably, your machine should have at least 64M of memory.

2.2.1. Installing GHC

Download the latest GHC distribution (ghc-4.08 InstallShield installer, 22M) from haskell.org It is packaged up using an installer that should be familiar-looking to Windows users. The 4.08 InstallShield package comes with some Cygwin binaries, which unfortunately won't work with another Cygwin installation on the same machine, unless it uses exactly the same version of the Cygwin DLL (1.3.1 in this InstallShield).

Note: The Cygwin support for long file names containing spaces is not 100%, so make sure that you install ghc in a directory that has no embedded spaces (i.e., resist the temptation to put it in /Program Files/!)

When the installer has completed, make sure you add the location of the ghc bin/ directory to your path (e.g. /ghc/ghc-4.08/bin ). You need to do this in order to bring the various GHC binaries into scope. Also, if the directory C:/TEMP doesn't already exist, you should create it.

To test the fruits of your labour, try now to compile a simple Haskell program:

bash$ cat main.hs
module Main(main) where

main = putStrLn "Hello, world!"
bash$ ghc -o main main.hs
bash$ ./main
Hello, world!

OK, assuming that worked, you're all set. Go forth and write useful Haskell programs :-) If not, consult the installation FAQ (Section 2.2.2); if that still doesn't help then please report the problems you're experiencing (see Chapter 8).

Further information on using GHC under Windows can be found in Sigbjørn Finne's pages. Note: ignore the installation instructions, which are rather out of date; the Miscellaneous section at the bottom of the page is of most interest, covering topics beyond the scope of this manual.

2.2.2. Installing ghc-win32 FAQ I'm having trouble with symlinks. I'm getting “permission denied” messages from rm or mv. I get errors when trying to build GHC 4.08 with GHC 4.05. I'm having trouble with symlinks.

Symlinks only work under Cygwin (Section, so binaries not linked to the Cygwin DLL, in particular those built for Mingwin, will not work with symlinks. I'm getting “permission denied” messages from rm or mv.

This can have various causes: trying to rename a directory when an Explorer window is open on it tends to fail. Closing the window generally cures the problem, but sometimes its cause is more mysterious, and logging off and back on or rebooting may be the quickest cure. I get errors when trying to build GHC 4.08 with GHC 4.05.

This seems to work better if you don't use -O in GhcHcOpts. It's a bug in 4.05, unfortunately. Anyway, better to install 4.08 binaries and use those.