1 <Chapter id="sec-installing-bin-distrib">
2 <Title>Installing from binary distributions</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
10 machine-generated C-files-from-Haskell for this purpose, but it's
11 really quite a pain to use them. If you must build GHC from its
12 sources, using a binary-distributed GHC to do so is a sensible way to
13 proceed. For the other <Literal>fptools</Literal> programs, many are written in Haskell,
14 so binary distributions allow you to install them without having a Haskell compiler.)
17 <Para>This guide is in two parts: installing on Unix-a-likes, and installing on Windows.</Para>
20 <Sect1><Title>Installing on Unix-a-likes</Title>
23 <Title>Bundle structure</Title>
26 <IndexTerm><Primary>bundles of binary stuff</Primary></IndexTerm>
30 Binary distributions come in ``bundles,'' one bundle per file called
31 <Literal><bundle>-<platform>.tar.gz</Literal>. (See the building guide for the definition of a platform.) Suppose that you untar a binary-distribution bundle, thus:
37 % cd /your/scratch/space
38 % gunzip < ghc-x.xx-sun-sparc-solaris2.tar.gz | tar xvf -
44 Then you should find a single directory, <Literal>fptools</Literal>, with the following
49 <IndexTerm><Primary>binary distribution, layout</Primary></IndexTerm>
50 <IndexTerm><Primary>directory layout (binary distributions)</Primary></IndexTerm>
54 <Term><Literal>Makefile.in</Literal></Term>
57 the raw material from which the <Literal>Makefile</Literal>
58 will be made (<Xref LinkEnd="sec-install">).
60 </ListItem></VarListEntry>
62 <Term><Literal>configure</Literal></Term>
65 the configuration script (<Xref LinkEnd="sec-install">).
67 </ListItem></VarListEntry>
69 <Term><Literal>README</Literal></Term>
72 Contains this file summary.
74 </ListItem></VarListEntry>
76 <Term><Literal>INSTALL</Literal></Term>
79 Contains this description of how to install
82 </ListItem></VarListEntry>
84 <Term><Literal>ANNOUNCE</Literal></Term>
87 The announcement message for the bundle.
89 </ListItem></VarListEntry>
91 <Term><Literal>NEWS</Literal></Term>
94 release notes for the bundle—a longer version
95 of <Literal>ANNOUNCE</Literal>. For GHC, the release notes are contained in the User
96 Guide and this file isn't present.
98 </ListItem></VarListEntry>
100 <Term><Literal>bin/<platform></Literal></Term>
103 contains platform-specific executable
104 files to be invoked directly by the user. These are the files that
105 must end up in your path.
107 </ListItem></VarListEntry>
109 <Term><Literal>lib/<platform>/</Literal></Term>
112 contains platform-specific support
113 files for the installation. Typically there is a subdirectory for
114 each <Literal>fptools</Literal> project, whose name is the name of the project with its
115 version number. For example, for GHC there would be a sub-directory
116 <Literal>ghc-x.xx</Literal>/ where <Literal>x.xx</Literal> is the version number of GHC in the bundle.
120 These sub-directories have the following general structure:
127 <Term><Literal>libHS.a</Literal> etc:</Term>
130 supporting library archives.
132 </ListItem></VarListEntry>
134 <Term><Literal>ghc-iface.prl</Literal> etc:</Term>
139 </ListItem></VarListEntry>
141 <Term><Literal>import/</Literal></Term>
144 <IndexTerm><Primary>Interface files</Primary></IndexTerm> (<Literal>.hi</Literal>) for the prelude.
146 </ListItem></VarListEntry>
148 <Term><Literal>include/</Literal></Term>
151 A few C <Literal>#include</Literal> files.
153 </ListItem></VarListEntry>
156 </ListItem></VarListEntry>
158 <Term><Literal>share/</Literal></Term>
161 contains platform-independent support files
162 for the installation. Again, there is a sub-directory for each
163 <Literal>fptools</Literal> project.
165 </ListItem></VarListEntry>
167 <Term><Literal>info/</Literal></Term>
170 contains Emacs info documentation files (one
171 sub-directory per project).
173 </ListItem></VarListEntry>
175 <Term><Literal>html/</Literal></Term>
178 contains HTML documentation files (one
179 sub-directory per project).
181 </ListItem></VarListEntry>
183 <Term><Literal>man/</Literal></Term>
186 contains Unix manual pages.
188 </ListItem></VarListEntry>
193 This structure is designed so that you can unpack multiple bundles
194 (including ones from different releases or platforms) into a single
195 <Literal>fptools</Literal> directory
199 this doesn't work at the
210 % cd /your/scratch/space
211 % gunzip < ghc-x.xx-sun-sparc-solaris2.tar.gz | tar xvf -
212 % gunzip < happy-x.xx-sun-sparc-sunos4.tar.gz | tar xvf -
218 When you do multiple unpacks like this, the top level <Literal>Makefile</Literal>,
219 <Literal>README</Literal>, and <Literal>INSTALL</Literal> get overwritten each time.
220 That's fine—they should be the same. Likewise, the
221 <Literal>ANNOUNCE-<bundle></Literal> and <Literal>NEWS-<bundle></Literal>
222 files will be duplicated across multiple platforms, so they will be
223 harmlessly overwritten when you do multiple unpacks. Finally, the
224 <Literal>share/</Literal> stuff will get harmlessly overwritten when you do
225 multiple unpacks for one bundle on different platforms.
228 <Sect3 id="sec-install">
229 <Title>Installing</Title>
232 OK, so let's assume that you have unpacked your chosen bundles into a
233 scratch directory <Literal>fptools</Literal>. What next? Well, you will at least need
234 to run the <Literal>configure</Literal><IndexTerm><Primary>configure</Primary></IndexTerm> script by changing your
235 directory to <Literal>fptools</Literal> and typing <Literal>./configure</Literal>. That should convert
236 <Literal>Makefile.in</Literal> to <Literal>Makefile</Literal>.
240 <IndexTerm><Primary>installing in-place</Primary></IndexTerm>
241 <IndexTerm><Primary>in-place installation</Primary></IndexTerm>
245 You can now either start using the tools <Emphasis>in-situ</Emphasis> without going
246 through any installation process, just type <Literal>make in-place</Literal> to set the
247 tools up for this. You'll also want to add the path which <Literal>make</Literal> will
248 now echo to your <Literal>PATH</Literal> environment variable. This option is useful if
249 you simply want to try out the package and/or you don't have the
250 necessary privileges (or inclination) to properly install the tools
251 locally. Note that if you do decide to install the package `properly'
252 at a later date, you have to go through the installation steps that
257 To install an <Literal>fptools</Literal> package, you'll have to do the following:
266 Edit the <Literal>Makefile</Literal> and check the settings of the following variables:
268 <IndexTerm><Primary>directories, installation</Primary></IndexTerm>
269 <IndexTerm><Primary>installation directories</Primary></IndexTerm>
274 <Term><Literal>platform</Literal></Term>
277 the platform you are going to install for.
279 </ListItem></VarListEntry>
281 <Term><Literal>bindir</Literal></Term>
284 the directory in which to install user-invokable
287 </ListItem></VarListEntry>
289 <Term><Literal>libdir</Literal></Term>
292 the directory in which to install
293 platform-dependent support files.
295 </ListItem></VarListEntry>
297 <Term><Literal>datadir</Literal></Term>
300 the directory in which to install
301 platform-independent support files.
303 </ListItem></VarListEntry>
305 <Term><Literal>infodir</Literal></Term>
308 the directory in which to install Emacs info
311 </ListItem></VarListEntry>
313 <Term><Literal>htmldir</Literal></Term>
316 the directory in which to install HTML
319 </ListItem></VarListEntry>
321 <Term><Literal>dvidir</Literal></Term>
324 the directory in which to install DVI
327 </ListItem></VarListEntry>
330 The values for these variables can be set through invocation of the
331 <Command>configure</Command><IndexTerm><Primary>configure</Primary></IndexTerm> script that comes with the distribution,
332 but doing an optical diff to see if the values match your expectations
333 is always a Good Idea.
335 <Emphasis>Instead of running <Command>configure</Command>, it is perfectly OK to copy
336 <Filename>Makefile.in</Filename> to <Filename>Makefile</Filename> and set all these variables
337 directly yourself. But do it right!</Emphasis>
344 Run <Literal>make install</Literal>. This <Emphasis> should</Emphasis> work with ordinary Unix
345 <Literal>make</Literal>—no need for fancy stuff like GNU <Literal>make</Literal>.
352 <Literal>rehash</Literal> (t?csh or zsh users), so your shell will see the new
353 stuff in your bin directory.
360 Once done, test your ``installation'' as suggested in
361 <XRef LinkEnd="sec-GHC-test">. Be sure to use a <Literal>-v</Literal>
362 option, so you can see exactly what pathnames it's using.
364 If things don't work as expected, check the list of know pitfalls in
374 <IndexTerm><Primary>link, installed as ghc</Primary></IndexTerm>
375 When installing the user-invokable binaries, this installation
376 procedure will install GHC as <Literal>ghc-x.xx</Literal> where <Literal>x.xx</Literal> is the version
377 number of GHC. It will also make a link (in the binary installation
378 directory) from <Literal>ghc</Literal> to <Literal>ghc-x.xx</Literal>. If you install multiple versions
379 of GHC then the last one ``wins'', and ``<Literal>ghc</Literal>'' will invoke the last
380 one installed. You can change this manually if you want. But
381 regardless, <Literal>ghc-x.xx</Literal> should always invoke GHC version <Literal>x.xx</Literal>.
388 <Title>What bundles there are</Title>
391 <IndexTerm><Primary>bundles, binary</Primary></IndexTerm>
392 There are plenty of ``non-basic'' GHC bundles. The files for them are
393 called <Literal>ghc-x.xx-<bundle>-<platform>.tar.gz</Literal>, where
394 the <Literal><platform></Literal> is as above, and <Literal><bundle></Literal> is one
402 <Term><Literal>prof</Literal>:</Term>
405 Profiling with cost-centres. You probably want this.
406 <IndexTerm><Primary>profiling bundles</Primary></IndexTerm>
407 <IndexTerm><Primary>bundles, profiling</Primary></IndexTerm>
409 </ListItem></VarListEntry>
411 <Term><Literal>conc</Literal>:</Term>
414 Concurrent Haskell features. You may want this.
415 <IndexTerm><Primary>concurrent bundles</Primary></IndexTerm>
416 <IndexTerm><Primary>bundles, concurrent</Primary></IndexTerm>
418 </ListItem></VarListEntry>
420 <Term><Literal>par</Literal>:</Term>
423 Parallel Haskell features (sits on top of PVM).
424 You'll want this if you're into that kind of thing.
425 <IndexTerm><Primary>parallel bundles</Primary></IndexTerm>
426 <IndexTerm><Primary>bundles, parallel</Primary></IndexTerm>
428 </ListItem></VarListEntry>
430 <Term><Literal>gran</Literal>:</Term>
433 The ``GranSim'' parallel-Haskell simulator
434 (hmm… mainly for implementors).
435 <IndexTerm><Primary>bundles, gransim</Primary></IndexTerm>
436 <IndexTerm><Primary>gransim bundles</Primary></IndexTerm>
438 </ListItem></VarListEntry>
440 <Term><Literal>ticky</Literal>:</Term>
443 ``Ticky-ticky'' profiling; very detailed
444 information about ``what happened when I ran this program''—really
446 <IndexTerm><Primary>bundles, ticky-ticky</Primary></IndexTerm>
447 <IndexTerm><Primary>ticky-ticky bundles</Primary></IndexTerm>
449 </ListItem></VarListEntry>
451 <Term><Literal>prof-conc</Literal>:</Term>
454 Cost-centre profiling for Concurrent Haskell.
455 <IndexTerm><Primary>bundles, profiled-concurrent</Primary></IndexTerm>
456 <IndexTerm><Primary>profiled-concurrent bundles</Primary></IndexTerm>
458 </ListItem></VarListEntry>
460 <Term><Literal>prof-ticky</Literal>:</Term>
463 Ticky-ticky profiling for Concurrent Haskell.
464 <IndexTerm><Primary>bundles, profiled-ticky</Primary></IndexTerm>
465 <IndexTerm><Primary>ticky-concurrent bundles</Primary></IndexTerm>
467 </ListItem></VarListEntry>
472 One likely scenario is that you will grab <Emphasis>three</Emphasis> binary
473 bundles—basic, profiling, and concurrent. We don't usually make the
474 rest, although you can build them yourself from a source distribution.
479 <Sect3 id="sec-GHC-test">
480 <Title>Testing that GHC seems to be working
484 <IndexTerm><Primary>testing a new GHC</Primary></IndexTerm>
488 The way to do this is, of course, to compile and run <Emphasis>this</Emphasis> program
489 (in a file <Literal>Main.hs</Literal>):
495 main = putStr "Hello, world!\n"
501 Compile the program, using the <Literal>-v</Literal> (verbose) flag to verify that
502 libraries, etc., are being found properly:
505 % ghc -v -o hello Main.hs
521 Some simple-but-profitable tests are to compile and run the notorious
522 <Literal>nfib</Literal><IndexTerm><Primary>nfib</Primary></IndexTerm> program, using different numeric types. Start with
523 <Literal>nfib :: Int -> Int</Literal>, and then try <Literal>Integer</Literal>, <Literal>Float</Literal>, <Literal>Double</Literal>,
524 <Literal>Rational</Literal> and perhaps the overloaded version. Code for this is
525 distributed in <Literal>ghc/misc/examples/nfib/</Literal> in a source distribution.
529 For more information on how to ``drive'' GHC, either do <Literal>ghc -help</Literal> or
530 consult the User's Guide (distributed in several pre-compiled formats
531 with a binary distribution, or in source form in
532 <Literal>ghc/docs/users_guide</Literal> in a source distribution).
542 <Sect1><Title>Installing on Windows</Title>
545 Getting the Glasgow Haskell Compiler(GHC) to run on Windows95/98 or
546 Windows NT4 platforms can be a bit of a trying experience. This document
547 tries to simplify the task by enumerating the steps you need to
548 follow in order to set up and configure your machine to run GHC (at
549 least that's the intention ;-)
552 <Sect2><Title>System requirements</Title>
555 An installation of GHC requires ca. 70M of disk space. The size of the
556 installed GHC distribution is just(!) 17M, the rest is needed by
561 To run GHC comfortably, your machine should have at least 32M of memory.
567 <Sect2><Title>Software required</Title>
571 <Term>The cygwin toolchain (beta20.1)</Term>
574 GHC depends at the moment on the cygwin tools to operate, which
575 dresses up the Win32 environment into something more UNIX-like.
576 (notably, it provides <Command>gcc</Command>, <Command>as</Command> and <Command>ld</Command>),
577 so you'll need to install these tools first.
585 The driver script is written in Perl, so you'll need to have this
586 installed too. However, the ghc binary distribution includes a
587 perl binary for you to make use of, should you not already have a
588 cygwin compatible one. Note: GHC does <Emphasis>not</Emphasis>
589 work with the ActiveState port of perl.
599 <Sect2><Title>Installing the supporting software</Title>
604 Download <ULink URL="http://sourceware.cygnus.com/cygwin/">cygwin beta20.1</ULink> (<Filename>full.exe</Filename>). Install this somewhere locally.
610 After having successfully installed this, make sure you do the following:
616 Create a <Filename>/bin</Filename> directory (using <Command>mkdir -p /bin</Command>).
622 Copy <Filename>bash.exe</Filename> from the <Filename>bin</Filename> directory of the cygwin tree (<Filename>cygwin-b20/H-i586-cygwin32/bin/bash.exe</Filename>) to
623 <Filename>/bin</Filename> as <Filename>sh.exe</Filename>.
629 If you haven't already got one, create a <Filename>/tmp</Filename> directory.
635 If you're an Emacs user and want to be able to run <Command>bash</Command>
636 from within a shell buffer, see the <ULink URL="http://www.cs.washington.edu/homes/voelker/ntemacs.html">NT Emacs home page</ULink> for
637 instructions on how to set this up.
648 With the supporting software in place, we can finally get on to installing GHC itself.
654 <Sect2><Title>Installing GHC</Title>
657 Download a GHC distribution:
663 <Term>ghc-4.045—InstallShield installer, 10M: <ULink URL="http://www.dcs.gla.ac.uk/~sof/ghc-4.045-win32-IS.zip">http</ULink> or <ULink URL="ftp://ftp.dcs.gla.ac.uk/pub/haskell/glasgow/4.04/ghc-4.045-win32-IS.zip">ftp</ULink>
668 Packaged up using an installer that should be familiar-looking to
669 Windows users. Unpack and double click on <Filename>setup.exe</Filename>.
673 Note: The cygwin support for long file names containing
674 spaces is not 100%, so make sure that you install ghc in a directory
675 that has no embedded spaces (i.e., resist the temptation to put it
676 in <Filename>/Program Files/</Filename>!)
680 When the installer has completed its job, you may delete the
681 <Filename>ghcInstall</Filename> directory.
685 When the installer has completed, make sure you add the location of the
686 ghc <Filename>bin/</Filename> directory to your path (i.e. <Filename>/path/to/wherever/ghc-4.05/bin </Filename>).
687 You need to do this in order to bring the various GHC DLLs into scope;
688 if not, then you need to copy the DLLs into a directory that is (the
689 system directory, for example).
693 Note: In case you haven't got perl already installed,
694 you will have to manually copy the <Filename>perl.exe</Filename> binary from the
695 ghc <Filename>bin/</Filename> into your <Filename>/bin</Filename> directory before continuing—the installer will not currently do this.
703 ghc-4.045 - gzip'ed tarfile, 7.5M: <ULink URL="http://www.dcs.gla.ac.uk/~sof/ghc-4.045-win32.tar.gz">
704 http</ULink> or <ULink URL="ftp://ftp.dcs.gla.ac.uk/pub/haskell/glasgow/4.04/ghc-4.045-win32.tar.gz">ftp</ULink>
709 A `normal' GHC binary distribution packaged up as a compressed tar file.
710 If you're already accustomed to installing and using GHC distributions
711 on other platforms, the setup should be familiar to you, I
712 hope. Unpack and read the INSTALL file contained in the
713 distribution for instructions on how to set it up.
717 Notice that the top directory of the distribution contains
718 (rather clumsily) a perl binary (version 5.005_02). If you
719 haven't already got a working perl, install this somewhere
728 To test the fruits of your labour, try now to compile a simple
734 module Main(main) where
736 main = putStrLn "Hello, world!"
737 bash$ /path/to/the/ghc/bin/directory/ghc-4.05 -o main main.hs
745 OK, assuming that worked, you're all set. Go forth and write useful
746 Haskell programs :-) If not, consult the installation FAQ (<XRef LinkEnd="winfaq">); if that still doesn't help then please report the problems you're experiencing (see <Xref LinkEnd="wrong">).
750 Further information on using GHC under Windows can be found in <ULink URL="http://www.dcs.gla.ac.uk/~sof/ghc-win32.html">Sigbjørn Finne's pages</ULink>.
758 <Sect1 id="winfaq"><title>Installing ghc-win32 FAQ</title>
766 Invoking ghc doesn't seem to do anything, it immediately returns without having compiled the input file.
772 One cause of this is that <Filename>/bin/sh</Filename> is missing. To verify, open up a
773 bash session and type <Command>ls -l /bin/sh.exe</Command>. If <Filename>sh.exe</Filename> is
774 reported as not being there, copy <Filename>bash.exe</Filename> (which you'll find
775 inside the cygwin installation tree as <Filename>H-i586-cygwin32/bin/bash.exe</Filename>)
776 to <Filename>/bin/sh.exe</Filename>.
780 All being well, ghc should then start to function.
790 When compiling up the <Literal>Hello World</Literal> example, the following happens:
794 bash$ /ghc/ghc-4.05/bin/ghc-4.05 main.hs
795 <stdin>:0:25: Character literal '{-# LINE 1 "main.hs" -}' too long
796 <stdin>:0:25: on input: "'"
805 bash$ /ghc/ghc-4.05/bin/ghc-4.05 main.hs
806 Program too big fit into memory under NT
813 The cause of this is that you're using a version of <Command>perl</Command> that employs the Microsoft <Command>cmd</Command>/<Command>command</Command> shell when launching sub-processes to execute <Function>system()</Function> calls.
817 The GHC driver really needs a <Command>perl</Command> which uses a `UNIX'y shell instead, so
818 make sure that the version you're using is of an compatible ilk. In particular,
819 if <Command>perl -v</Command> reports that you've got a copy of the (otherwise fine) port
820 of perl done by ActiveState, you're in trouble.
824 If you're stuck with an incompatible <Command>perl</Command>, the GHC installation comes with a very basic <Command>perl</Command> binary for you to use. Simply copy it into the <Command>/bin</Command> directory.
828 Notice that copying <Filename>perl.exe</Filename> into <Filename>/bin</Filename> will not cause
829 the GHC install to suddenly start functioning. If you don't want to
830 re-run the InstallShield installer again, you need to edit the following
831 files within the directory tree that the installer created:
835 bin/ghc-4.xx -- where xx is the minor release number
842 For each of these files, you need to edit the first line from instead
843 saying <Command>#!/path/to/your/other/perl/install</Command> to <Command>#!/bin/perl</Command>.
844 Once that is done, try compiling up the Hello, World example again.
848 Should you want to pick up a complete installation of a ghc-friendly port
849 of perl instead, a <ULink URL="http://cygutils.netpedia.net/">cygwin port</ULink> is available.
859 <Function>System.getArgs</Function> always return the empty list, i.e. the following program always prints <Screen>"[]"</Screen>:
863 module Main(main) where
864 import qualified System
865 main = System.getArgs >>= print
872 This is a bug with the RTS DLL that comes with ghc-4.03. To fix, upgrade to