When programming Haskell, I usually hack in a GHCi interactive session. So I was surprise when I tried to make a test executable the other day:
ralph@vegeta:~/src/haskell$ ghc --make Hello [1 of 1] Compiling Main ( Hello.hs, Hello.o ) Linking Hello ... /usr/bin/ld: cannot find -lgmp collect2: ld returned 1 exit status
libgmp is a library for arbitrary precision arithmetic, which is something Haskell does well. So, I was surprise that I was getting this message. The obvious solution is install the Ubuntu package for libgmp:
ralph@vegeta:~/src/haskell$ sudo apt-get install libgmp3c2 Reading package lists... Done Building dependency tree Reading state information... Done libgmp3c2 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.
Well that was strange! So, I searched for libgmp on my system:
ralph@vegeta:~/src/haskell$ find /usr/lib/ -name libgmp* /usr/lib/ssl/engines/libgmp.so /usr/lib/libgmp.so.3.5.2 /usr/lib/libgmp.so.3
There is no libgmp.so symlink, so I just created one:
ralph@vegeta:~/src/haskell$ cd /usr/lib ralph@vegeta:/usr/lib$ sudo ln -s libgmp.so.3 libgmp.so
Now everything compiles and links:
ralph@vegeta:~/src/haskell$ ghc --make Hello [1 of 1] Compiling Main ( Hello.hs, Hello.o ) Linking Hello ...