1 <Chapter id="sec-installing-bin-distrib">
2 <Title>Installing GHC</Title>
3 <IndexTerm><Primary>binary installations</Primary></IndexTerm>
4 <IndexTerm><Primary>installation, of binaries</Primary></IndexTerm>
7 Installing from binary distributions is easiest, and recommended!
8 (Why binaries? Because GHC is a Haskell compiler written in Haskell,
9 so you've got to bootstrap it somehow. We provide machine-generated
10 C-files-from-Haskell for this purpose, but it's really quite a pain to
11 use them. If you must build GHC from its sources, using a
12 binary-distributed GHC to do so is a sensible way to proceed. For the
13 other <Literal>fptools</Literal> programs, many are written in
14 Haskell, so binary distributions allow you to install them without
15 having a Haskell compiler.)
18 <Para>This guide is in several parts:</para>
22 <para> Installing on Unix-a-likes (<Xref
23 LinkEnd="sec-unix-a-likes">). </para>
26 <para> Installing on Windows (<Xref
27 LinkEnd="sec-install-windows">). </para>
30 <para> The layout of installed files (<Xref
31 LinkEnd="sec-install-files">). You don't need to know this to
32 install GHC, but it's useful if you are changing the
33 implementation.</para>
37 <Sect1 id="sec-unix-a-likes"><Title>Installing on Unix-a-likes</Title>
40 <title>When a platform-specific package is available</title>
42 <para>For certain platforms, we provide GHC binaries packaged
43 using the native package format for the platform. This is
44 likely to be by far the best way to install GHC for your
45 platform if one of these packages is available, since
46 dependencies will automatically be handled and the package
47 system normally provides a way to uninstall the package at a
50 <para>We generally provide the following packages:</para>
54 <term>RedHat or SuSE Linux/x86</term>
56 <para>RPM source & binary packages for RedHat and SuSE
57 Linux (x86 only) are available for most major
63 <term>Debian Linux/x86</term>
65 <para>Debian packages for Linux (x86 only), also for most
66 major releases.</para>
71 <term>FreeBSD/x86</term>
73 <para>On FreeBSD/x86, GHC can be installed using either
74 the ports tree (<literal>cd /usr/ports/lang/ghc && make
75 install</literal>) or from a pre-compiled package
76 available from your local FreeBSD mirror.</para>
81 <para>Other platform-specific packages may be available, check
82 the GHC download page for details.</para>
86 <Title>GHC binary distributions</Title>
89 <IndexTerm><Primary>bundles of binary stuff</Primary></IndexTerm>
93 Binary distributions come in “bundles,” one bundle per file called
94 <literal><replaceable>bundle</replaceable>-<replaceable>platform</replaceable>.tar.gz</Literal>. (See the building guide for the definition of a platform.) Suppose that you untar a binary-distribution bundle, thus:
100 % cd /your/scratch/space
101 % gunzip < ghc-x.xx-sun-sparc-solaris2.tar.gz | tar xvf -</Screen>
106 Then you should find a single directory,
107 <Literal>ghc-<replaceable>version</replaceable></Literal>, with the
112 <IndexTerm><Primary>binary distribution, layout</Primary></IndexTerm>
113 <IndexTerm><Primary>directory layout (binary distributions)</Primary></IndexTerm>
117 <Term><Literal>Makefile.in</Literal></Term>
120 the raw material from which the <Literal>Makefile</Literal>
121 will be made (<Xref LinkEnd="sec-install">).
123 </ListItem></VarListEntry>
125 <Term><Literal>configure</Literal></Term>
128 the configuration script (<Xref LinkEnd="sec-install">).
130 </ListItem></VarListEntry>
132 <Term><Literal>README</Literal></Term>
135 Contains this file summary.
137 </ListItem></VarListEntry>
139 <Term><Literal>INSTALL</Literal></Term>
142 Contains this description of how to install
145 </ListItem></VarListEntry>
147 <Term><Literal>ANNOUNCE</Literal></Term>
150 The announcement message for the bundle.
152 </ListItem></VarListEntry>
154 <Term><Literal>NEWS</Literal></Term>
157 release notes for the bundle—a longer version
158 of <Literal>ANNOUNCE</Literal>. For GHC, the release notes are contained in the User
159 Guide and this file isn't present.
161 </ListItem></VarListEntry>
163 <Term><Literal>bin/<replaceable>platform</replaceable></Literal></Term>
166 contains platform-specific executable
167 files to be invoked directly by the user. These are the files that
168 must end up in your path.
170 </ListItem></VarListEntry>
172 <Term><Literal>lib/<replaceable>platform</replaceable>/</Literal></Term>
175 contains platform-specific support
176 files for the installation. Typically there is a subdirectory for
177 each <Literal>fptools</Literal> project, whose name is the name of the project with its
178 version number. For example, for GHC there would be a sub-directory
179 <Literal>ghc-x.xx</Literal>/ where <Literal>x.xx</Literal> is the version number of GHC in the bundle.
183 These sub-directories have the following general structure:
190 <Term><Literal>libHSstd.a</Literal> etc:</Term>
193 supporting library archives.
195 </ListItem></VarListEntry>
197 <Term><Literal>ghc-iface.prl</Literal> etc:</Term>
202 </ListItem></VarListEntry>
204 <Term><Literal>import/</Literal></Term>
207 <IndexTerm><Primary>Interface files</Primary></IndexTerm> (<Literal>.hi</Literal>) for the prelude.
209 </ListItem></VarListEntry>
211 <Term><Literal>include/</Literal></Term>
214 A few C <Literal>#include</Literal> files.
216 </ListItem></VarListEntry>
219 </ListItem></VarListEntry>
221 <Term><Literal>share/</Literal></Term>
224 contains platform-independent support files
225 for the installation. Again, there is a sub-directory for each
226 <Literal>fptools</Literal> project.
228 </ListItem></VarListEntry>
230 <Term><Literal>html/</Literal></Term>
233 contains HTML documentation files (one
234 sub-directory per project).
236 </ListItem></VarListEntry>
240 <Sect3 id="sec-install">
241 <Title>Installing</Title>
244 OK, so let's assume that you have unpacked your chosen bundles. What
245 next? Well, you will at least need to run the
246 <Literal>configure</Literal><IndexTerm><Primary>configure</Primary></IndexTerm>
247 script by changing directory into the top-level directory for the
248 bundle and typing <Literal>./configure</Literal>. That should convert
249 <Literal>Makefile.in</Literal> to <Literal>Makefile</Literal>.
253 <IndexTerm><Primary>installing in-place</Primary></IndexTerm>
254 <IndexTerm><Primary>in-place installation</Primary></IndexTerm>
255 You can now either start using the tools <Emphasis>in-situ</Emphasis> without going
256 through any installation process, just type <Literal>make in-place</Literal> to set the
257 tools up for this. You'll also want to add the path which <Literal>make</Literal> will
258 now echo to your <Literal>PATH</Literal> environment variable. This option is useful if
259 you simply want to try out the package and/or you don't have the
260 necessary privileges (or inclination) to properly install the tools
261 locally. Note that if you do decide to install the package `properly'
262 at a later date, you have to go through the installation steps that
267 To install a package, you'll have to do the following:
276 Edit the <Literal>Makefile</Literal> and check the settings of the following variables:
278 <IndexTerm><Primary>directories, installation</Primary></IndexTerm>
279 <IndexTerm><Primary>installation directories</Primary></IndexTerm>
284 <Term><Literal>platform</Literal></Term>
287 the platform you are going to install for.
289 </ListItem></VarListEntry>
291 <Term><Literal>bindir</Literal></Term>
294 the directory in which to install user-invokable
297 </ListItem></VarListEntry>
299 <Term><Literal>libdir</Literal></Term>
302 the directory in which to install
303 platform-dependent support files.
305 </ListItem></VarListEntry>
307 <Term><Literal>datadir</Literal></Term>
310 the directory in which to install
311 platform-independent support files.
313 </ListItem></VarListEntry>
315 <Term><Literal>infodir</Literal></Term>
318 the directory in which to install Emacs info
321 </ListItem></VarListEntry>
323 <Term><Literal>htmldir</Literal></Term>
326 the directory in which to install HTML
329 </ListItem></VarListEntry>
331 <Term><Literal>dvidir</Literal></Term>
334 the directory in which to install DVI
337 </ListItem></VarListEntry>
340 The values for these variables can be set through invocation of the
341 <Command>configure</Command><IndexTerm><Primary>configure</Primary></IndexTerm>
342 script that comes with the distribution, but doing an optical diff to
343 see if the values match your expectations is always a Good Idea.
347 <Emphasis>Instead of running <Command>configure</Command>, it is
348 perfectly OK to copy <Filename>Makefile.in</Filename> to
349 <Filename>Makefile</Filename> and set all these variables directly
350 yourself. But do it right!</Emphasis>
357 Run <Literal>make install</Literal>. This <Emphasis>
358 should</Emphasis> work with ordinary Unix
359 <Literal>make</Literal>—no need for fancy stuff like GNU
360 <Literal>make</Literal>.
367 <Literal>rehash</Literal> (t?csh or zsh users), so your shell will see the new
368 stuff in your bin directory.
375 Once done, test your “installation” as suggested in
376 <XRef LinkEnd="sec-GHC-test">. Be sure to use a <Literal>-v</Literal>
377 option, so you can see exactly what pathnames it's using.
379 If things don't work as expected, check the list of known pitfalls in
389 <IndexTerm><Primary>link, installed as ghc</Primary></IndexTerm>
390 When installing the user-invokable binaries, this installation
391 procedure will install GHC as <Literal>ghc-x.xx</Literal> where <Literal>x.xx</Literal> is the version
392 number of GHC. It will also make a link (in the binary installation
393 directory) from <Literal>ghc</Literal> to <Literal>ghc-x.xx</Literal>. If you install multiple versions
394 of GHC then the last one “wins”, and “<Literal>ghc</Literal>” will invoke the last
395 one installed. You can change this manually if you want. But
396 regardless, <Literal>ghc-x.xx</Literal> should always invoke GHC version <Literal>x.xx</Literal>.
403 <Title>What bundles there are</Title>
406 <IndexTerm><Primary>bundles, binary</Primary></IndexTerm> There are
407 plenty of “non-basic” GHC bundles. The files for them are
409 <Literal>ghc-x.xx-<replaceable>bundle</replaceable>-<replaceable>platform</replaceable>.tar.gz</Literal>,
410 where the <replaceable>platform</replaceable> is as above, and
411 <replaceable>bundle</replaceable> is one of these:
418 <Term><Literal>prof</Literal>:</Term>
421 Profiling with cost-centres. You probably want this.
422 <IndexTerm><Primary>profiling bundles</Primary></IndexTerm>
423 <IndexTerm><Primary>bundles, profiling</Primary></IndexTerm>
425 </ListItem></VarListEntry>
427 <Term><Literal>par</Literal>:</Term>
430 Parallel Haskell features (sits on top of PVM).
431 You'll want this if you're into that kind of thing.
432 <IndexTerm><Primary>parallel bundles</Primary></IndexTerm>
433 <IndexTerm><Primary>bundles, parallel</Primary></IndexTerm>
435 </ListItem></VarListEntry>
437 <Term><Literal>gran</Literal>:</Term>
440 The “GranSim” parallel-Haskell simulator
441 (hmm… mainly for implementors).
442 <IndexTerm><Primary>bundles, gransim</Primary></IndexTerm>
443 <IndexTerm><Primary>gransim bundles</Primary></IndexTerm>
445 </ListItem></VarListEntry>
447 <Term><Literal>ticky</Literal>:</Term>
450 “Ticky-ticky” profiling; very detailed
451 information about “what happened when I ran this program”—really
453 <IndexTerm><Primary>bundles, ticky-ticky</Primary></IndexTerm>
454 <IndexTerm><Primary>ticky-ticky bundles</Primary></IndexTerm>
456 </ListItem></VarListEntry>
461 One likely scenario is that you will grab <Emphasis>two</Emphasis>
462 binary bundles—basic, and profiling. We don't usually make the
463 rest, although you can build them yourself from a source distribution.
466 <para>The various GHC bundles are designed to be unpacked into the
467 same directory; then installing as per the directions above will
468 install the whole lot in one go. Note: you <emphasis>must</emphasis>
469 at least have the basic GHC binary distribution bundle, these extra
470 bundles won't install on their own.</para>
474 <Sect3 id="sec-GHC-test">
475 <Title>Testing that GHC seems to be working
479 <IndexTerm><Primary>testing a new GHC</Primary></IndexTerm>
483 The way to do this is, of course, to compile and run <Emphasis>this</Emphasis> program
484 (in a file <Literal>Main.hs</Literal>):
490 main = putStr "Hello, world!\n"
496 Compile the program, using the <Literal>-v</Literal> (verbose) flag to verify that
497 libraries, etc., are being found properly:
500 % ghc -v -o hello Main.hs</Screen>
509 Hello, world!</Screen>
514 Some simple-but-profitable tests are to compile and run the notorious
515 <Literal>nfib</Literal><IndexTerm><Primary>nfib</Primary></IndexTerm> program, using different numeric types. Start with
516 <Literal>nfib :: Int -> Int</Literal>, and then try <Literal>Integer</Literal>, <Literal>Float</Literal>, <Literal>Double</Literal>,
517 <Literal>Rational</Literal> and perhaps the overloaded version. Code for this is
518 distributed in <Literal>ghc/misc/examples/nfib/</Literal> in a source distribution.
521 <para>For more information on how to “drive” GHC, read
531 <Sect1 id="sec-install-windows"><Title>Installing on Windows</Title>
534 Getting the Glasgow Haskell Compiler (post 5.02) to run on Windows platforms is
535 a snap: the Installshield does everything you need.
538 <Sect2><Title>Installing GHC on Windows</Title>
541 To install GHC, use the following steps:
544 <listitem><para>Download the Installshield <Filename>setup.exe</Filename>
545 from the GHC download page
547 URL="http://www.haskell.org/ghc">haskell.org</ULink>.
550 <listitem><para>Run <Filename>setup.exe</Filename>.
551 On Windows, all of GHC's files are installed in a single directory.
552 If you choose ``Custom'' from the list of install options, you will be given a
553 choice about where this directory is; otherwise it will be installed
554 in <filename>c:/ghc/<emphasis>ghc-version</emphasis></filename>.
555 The executable binary for GHC will be installed in the <filename>bin/</filename> sub-directory
556 of the installation directory you choose.
558 <para>(If you have already installed the same version of GHC, Installshield will offer to "modify",
559 or "remove" GHC. Choose "remove"; then run <Filename>setup.exe</Filename> a
560 second time. This time it should offer to install.)
563 When installation is complete, you should find GHCi and the GHC documentation are
564 available in your Start menu under "Start/Programs/Glasgow Haskell Compiler".
569 The final dialogue box from the install process reminds you where the GHC binary
570 has been installed (usually <filename>c:/ghc/<emphasis>ghc-version</emphasis>/bin/</filename>.
571 If you want to invoke GHC from a command line, add this
572 to your PATH environment variable.
576 GHC needs a directory in which to create, and later delete, temporary files.
577 It uses the standard Windows procedure <literal>GetTempPath()</literal> to
578 find a suitable directory. This procedure returns:
580 <listitem><para>The path in environment variable TMP,
581 if TMP is set.</para></listitem>
582 <listitem><para>Otherwise, the path in environment variable TEMP,
583 if TEMP is set.</para></listitem>
584 <listitem><para>Otherwise, there is a per-user default which varies
585 between versions of Windows. On NT and XP-ish versions, it might
587 <Filename>c:\Documents and Settings\<username>\Local Settings\Temp</filename>
590 The main point is that if you don't do anything GHC will work fine;
591 but if you want to control where the directory is, you can do so by
597 To test the fruits of your labour, try now to compile a simple
603 module Main(main) where
605 main = putStrLn "Hello, world!"
606 bash$ ghc -o main main.hs
615 You do <emphasis>not</emphasis> need the Cygwin toolchain, or anything
616 else, to install and run GHC.
619 An installation of GHC requires about 140M of disk space.
620 To run GHC comfortably, your machine should have at least
625 <Sect2><title>Moving GHC around</title>
627 At the moment, GHC installs in a fixed place (<Filename>c:/ghc/ghc-x.yy</Filename>,
628 but once it is installed, you can freely move the entire GHC tree just by copying
629 the <Filename>ghc-x.yy</Filename> directory. (You may need to fix up
630 the links in "Start/Programs/Glasgow Haskell Compiler" if you do this.)
633 It is OK to put GHC tree in a directory whose path involves spaces. However,
634 don't do this if you use want to use GHC with the Cygwin tools,
635 because Cygwin can get confused when this happpens.
636 We havn't quite got to the bottom of this, but so far as we know it's not
637 a problem with GHC itself. Nevertheless, just to keep life simple we usually
638 put GHC in a place with a space-free path.
642 <Sect2 id="winfaq"><title>Installing ghc-win32 FAQ</title>
650 I'm having trouble with symlinks.
656 Symlinks only work under Cygwin (<Xref LinkEnd="sec-install">), so binaries
657 not linked to the Cygwin DLL, in particular those built for Mingwin, will not
668 I'm getting “permission denied” messages from the <Command>rm</Command> or
669 <Command>mv</Command>.
675 This can have various causes: trying to rename a directory when an Explorer
676 window is open on it tends to fail. Closing the window generally cures the
677 problem, but sometimes its cause is more mysterious, and logging off and back
678 on or rebooting may be the quickest cure.
686 <!-- doesn't add much value any longer; leave out [sof 7/2002].
688 Further information on using GHC under Windows can be found in <ULink
689 URL="http://www.dcs.gla.ac.uk/~sof/ghc-win32.html">Sigbjørn Finne's
690 pages</ULink>. Note: ignore the installation instructions, which are rather
691 out of date; the <Emphasis>Miscellaneous</Emphasis> section at the bottom of
692 the page is of most interest, covering topics beyond the scope of this
701 <Sect1 id="sec-install-files"><Title>The layout of installed files</Title>
704 This section describes what files get installed where. You don't need to know it
705 if you are simply installing GHC, but it is vital information if you are changing
708 <para> GHC is installed in two directory trees:</para>
711 <term>Library directory,</term>
712 <listitem> <para> known as <Filename>$(libdir)</Filename>, holds all the
713 support files needed to run GHC. On Unix, this
714 directory is usually something like <Filename>/usr/lib/ghc/ghc-5.02</Filename>. </para>
718 <term>Binary directory</term>
719 <listitem> <para> known as <Filename>$(bindir)</Filename>, holds executables that
720 the user is expected to invoke.
722 <Filename>ghc</Filename> and <Filename>ghci</FileName>. On Unix, this directory
723 can be anywhere, but is typically something like <Filename>/usr/local/bin</Filename>. On Windows,
724 however, this directory <emphasis>must be</emphasis> <Filename>$(libdir)/bin</Filename>.
731 When GHC runs, it must know where its library directory is.
732 It finds this out in one of two ways:
737 <Filename>$(libdir)</Filename> is passed to GHC using the <option>-B</option> flag.
738 On Unix (but not Windows), the installed <filename>ghc</filename> is just a one-line
739 shell script that invokes the real GHC, passing a suitable <option>-B</option> flag.
740 [All the user-supplied flags
741 follow, and a later <option>-B</option> flag overrides an earlier one, so a user-supplied
746 <para> On Windows (but not Unix), if no <option>-B</option> flag is given, GHC uses a system
747 call to find the directory in which the running GHC executable lives, and derives
748 <Filename>$(libdir)</Filename> from that. [Unix lacks such a system call.]
749 That is why <Filename>$(bindir)</Filename> must be <Filename>$(libdir)/bin</Filename>.
754 <sect2> <title>The binary directory</title>
756 <para>The binary directory, <Filename>$(bindir)</Filename> contains user-visible
757 executables, notably <filename>ghc</filename> and <filename>ghci</filename>.
758 You should add it to your <literal>$PATH</literal>
761 <para>On Unix, the user-invokable <filename>ghc</filename> invokes <filename>$(libdir)/ghc-<replaceable>version</replaceable></filename>,
762 passing a suitable <option>-B</option> flag to tell <filename>ghc-<replaceable>version</replaceable></filename> where
763 <Filename>$(libdir)</Filename> is.
764 Similarly <filename>ghci</filename>, except the extra flag <literal>--interactive</literal> is passed.
767 <para>On Win32, the user-invokable <filename>ghc</filename> binary
768 is the Real Thing (no intervening
769 shell scripts or <filename>.bat</filename> files).
770 Reason: we sometimes invoke GHC with very long command lines,
771 and <filename>cmd.exe</filename> (which executes <filename>.bat</filename> files)
772 truncates them. Similarly <filename>ghci</filename> is a C wrapper program that invokes <filename>ghc --interactive</filename>
773 (passing on all other arguments), not a <filename>.bat</filename> file.
779 <sect2> <title>The library directory</title>
781 <para>The layout of the library directory, <filename>$(libdir)</filename> is almost identical on
782 Windows and Unix, as follows. Differences between Windows and Unix
783 are noted thus <literal>[Win32 only]</literal> and are commented below.</para>
787 package.conf GHC package configuration
788 ghc-usage.txt Message displayed by ghc ––help
790 bin/ [Win32 only] User-visible binaries
794 unlit Remove literate markup
796 touchy.exe [Win32 only]
797 perl.exe [Win32 only]
800 ghc-x.xx GHC executable [Unix only]
802 ghc-split Asm code splitter
803 ghc-asm Asm code mangler
805 gcc-lib/ [Win32 only] Support files for gcc
806 specs gcc configuration
808 cpp0.exe gcc support binaries
815 libmingw32.a Standard
820 imports/ GHC interface files
821 std/*.hi 'std' library
822 lang/*.hi 'lang' library
825 include/ C header files
826 StgMacros.h GHC-specific
827 ..etc... header files
829 mingw/*.h [Win32 only] Mingwin header files
831 libHSrts.a GHC library archives
836 HSstd1.o GHC library linkables
837 HSstd2.o (used by ghci, which does
838 HSlang.o not grok .a files yet)
845 <para><filename>$(libdir)</filename> also contains support
846 binaries. These are <emphasis>not</emphasis> expected to be
847 on the user's <filename>PATH</filename>, but and are invoked
848 directly by GHC. In the Makefile system, this directory is
849 also called <filename>$(libexecdir)</filename>, but
850 <emphasis>you are not free to change it</emphasis>. It must
851 be the same as <filename>$(libdir)</filename>.</para>
855 <para>We distribute <filename>gcc</filename> with the Win32 distribution of GHC, so that users
856 don't need to install <filename>gcc</filename>, nor need to care about which version it is.
857 All <filename>gcc</filename>'s support files are kept in <filename>$(libdir)/gcc-lib/</filename>.
862 <para>Similarly, we distribute <filename>perl</filename> and a <filename>touch</filename>
863 replacement (<filename>touchy.exe</filename>)
864 with the Win32 distribution of GHC. </para>
868 <para>The support programs <filename>ghc-split</filename>
869 and <filename>ghc-asm</filename> are Perl scripts. The
870 first line says <literal>#!/bin/perl</literal>; on Unix, the
871 script is indeed invoked as a shell script, which invokes
872 Perl; on Windows, GHC invokes
873 <filename>$(libdir)/perl.exe</filename> directly, which
874 treats the <literal>#!/bin/perl</literal> as a comment.
875 Reason: on Windows we want to invoke the Perl distributed
876 with GHC, rather than assume some installed one. </para>
888 ;;; Local Variables: ***
890 ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***