views:

82

answers:

1

I have been trying to install Haskell Platform and cabal-install installed on Linux in user-space on a system that doesn't have the GNU Multi-Precision package (GMP) installed.

I managed to get GHC-6.12.1 installed and ghci working by setting up LB_LIBRARY_PATH to point at the lib directory where I installed GMP, but then ran into problems in the next step, getting cabal-install to work. It kept trying to (statically) link to gmp.

This fails because the GMP is not installed in the system and ld hasn't a clue where to find the libraries, and there is no environment variable (that I am aware of) that can tell ld where to find the user-installed GMP, and (apparently) no way of telling configuring cabal to supply the relevant -L flag.

After much fruitless searching and hacking attempts I hit on the absurdly simple idea of installing my own ld shell script that invokes the system ld with the appropriate -L flag.

This is shell scripting 101, of course:

#!/bin/sh /usr/bin/ld -L$HOME/gnu/lib "$@"

With this script installed in a directory on my PATH ahead of /usr/bin all the problems seem to have gone away.

A: 

Basically, your ghc is not working yet. Yes, it can compile things, but it cannot link programs because it needs to link them to gmp.

What we can do is to edit some core package, e.g. the rts package, so that ghc will always use the right -L flag:

ghc-pkg describe rts > rts.pkg
vi rts.pkg                      # add the gmp dir to the `library-dirs` field
sudo ghc-pkg update rts.pkg
Duncan Coutts