31

I am trying to install the Haskell Platform on Linux for the first time (I'm also a fairly new Linux user). The victim system is a fresh Red Hat system. And everything involved here should be 64 bit.

The directions at the platform website [1] indicate that I need a ghc7.0.3 to boostrap things. They provide a link to a generic binary of ghc-7.0.3 to do this. I fetched this and ran

$ ./configure ...
$ make install ...

as per the directions without incident (it is a binary, so no compilation needed) However, when I tried to run ghci I get the output.

$ ghci
GHCi, version 7.0.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... <command line>: can't load .so/.DLL for: gmp (libgmp.so: cannot open shared object file: No such file or directory)

For some reason ghci cannot find libgmp.so. Running ghci ultimately invokes

  /usr/local/lib/ghc-7.0.3/ghc

with a mess of options. I checked the dependencies via ldd

$ ldd /usr/local/lib/ghc-7.0.3/ghc
    linux-vdso.so.1 =>  (0x00007fffe5f5c000)
    libncursesw.so.5 => /lib64/libncursesw.so.5 (0x0000003ee7000000)
    librt.so.1 => /lib64/librt.so.1 (0x0000003ee5800000)
    libutil.so.1 => /lib64/libutil.so.1 (0x0000003ef3000000)
    libdl.so.2 => /lib64/libdl.so.2 (0x0000003ee5000000)
    libgmp.so.3 => /usr/lib64/libgmp.so.3 (0x0000003ee4400000)
    libm.so.6 => /lib64/libm.so.6 (0x0000003ee4c00000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003ee5400000)
    libc.so.6 => /lib64/libc.so.6 (0x0000003ee4800000)
    libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003ef3400000)
    /lib64/ld-linux-x86-64.so.2 (0x0000003ee4000000)

and it shows that it foud libgmp. libgmp is in /usr/local/lib and /usr/local/lib64. I am not sure how to get further with this. Any suggestions?

[1] http://hackage.haskell.org/platform/linux.html

Tim
  • 2,708
  • 1
  • 18
  • 32

3 Answers3

35

You either add /usr/local/lib and/or /usr/local/lib64 to $LD_LIBRARY_PATH, or add them to /etc/ld.so.conf, or (since you already have /usr/lib64/libgmp.so.3) add a missing symbolic link:

cd /usr/lib64
sudo ln -s libgmp.so.3 libgmp.so

(and perhaps the same for /usr/lib).

Note that /usr/lib64/libgmp.so.3 might be a different version from /usr/local/lib64/libgmp.so, make sure ghc can actually be used with the former.

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
  • 1
    Many thanks. Setting LD_LIBRARY_PATH to /usr/local/lib fixed this as well as adding the symlink in /usr/lib64 targeting libgmp.so.3. I guess I am still puzzled, I assumed since ldd found /usr/lib64/libgmp.so.3, why'd it fail without the libgmp.so symlink? – Tim Jun 15 '11 at 22:13
  • 4
    I don't know if I'm right about this, but I just read somewhere that symlinking binaries or libraries is a very bad idea. Some guy said and I quote: "Never symlink binaries unless you've a gun pointed at you". Anyway, I just followed your answer and it worked. I'm just not sure if this is the best way. – Abdulsattar Mohammed Nov 24 '11 at 13:04
  • Just a note for non-standard libgmp.so.3 -> newer with non-standard libgmp. ghc's ld step doesn't know about LD_LIBRARY_PATH, so linking apps using ghc will break, even though ghc/ghci/etc. will run. –  Jan 25 '14 at 04:38
  • 8
    On ubuntu (and maybe debian) you can fix the library error by installing the `libgmp3c2` package. This avoids the symlink hack. – Bakuriu Jun 23 '14 at 20:23
  • 2
    GHC now has separate builds based on CentOS and Debian. Your problem might be that you downloaded the wrong one. (The suggestions above will still likely work for you, though.) – Elliot Cameron Jul 22 '14 at 20:56
  • 10
    @Bakuriu 's comment above works - for ubuntu 14 it worked for me with `libgmp3-dev` (my apt didn't know about `libgmp3c2`) – sinelaw Sep 02 '14 at 19:52
  • @asattar I love how Linux people say big, mysterious things like that and then don't explain them. (I consider myself a Linux person, so that is not an outsider's criticism.) – Keith Pinson Nov 15 '14 at 17:07
  • 1
    @sinelaw, Thanks ! That's works great for me as well on Ubuntu 14. sudo apt-get install libgmp3-dev – Knowself Dec 09 '14 at 23:28
18

Installing gmp-devel package helped in my case (opensuse)

Andriy F.
  • 2,467
  • 1
  • 25
  • 23
5

I'm not sure that setting a symbolic link from libgmp.so to libgmp.so.3 is the right way to go. What happens when you get a version update and so libgmp.so.3 disappears. Setting LD_LIBRARY_PATH seems like a better solution.

There's also another solution for RedHat/CentOS and by extension probably Fedora: install the gmp-devel package. This sets up the symbolic link above, but does so with in the distribution (so updates should update the symbolic link also).

dave
  • 4,812
  • 4
  • 25
  • 38
  • Installing gmp-devel on Fedora works great. This creates a new symbolic link (libgmp.so) pointing to whatever version is currently installed and, as a result, ghci runs. – Avinash Meetoo Dec 13 '15 at 05:10