Using GHC, cabal with GMP installed in user-space
Asked Answered
M

1

8

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.

Markusmarl answered 1/4, 2010 at 4:42 Comment(0)
L
10

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
Licensee answered 14/10, 2010 at 7:41 Comment(3)
For those people who've installed GHC in a user directory, they'll be able to execute the last command with sudo. When I manually edited the rts.pkg, I didn't know what kind of field separater cabal used, so I just put the extra library directory on its own line after the original.Bequest
The separator for these library dirs is just space.Clearheaded
Copy the libgmp.so to one of the include-dirs e.g. /home/dilawar/bin/lib/ghc-7.8.3/rts-1.0. It worked for me.Overby

© 2022 - 2024 — McMap. All rights reserved.