2

Whenever I try to compile an executable with ghc --make, I am getting the following error when trying to execute the program afterwards, despite there being no errors upon compilation:

./main: error while loading shared libraries: libffi.so.4: cannot open shared object  file: No such file or directory

(It works fine if I load the programs into ghci though)

Here's a minimal example program that used to work, but now doesn't (I don't know why)

module Main(main)
where

main = do c <- getContents
          putStr c

I am using GHC 7.0.3, on Ubuntu 11.10. Help would be appreciated.

Update: Removing and reinstalling from the package manager didn't fix it either. I do have libffi5 and libffi6, how do I get ghc to use one of these instead of libffi4?

Cubic
  • 14,902
  • 5
  • 47
  • 92
  • How did you install GHC? On Ubuntu 11.10, libffi.so.5 and libffi.so.6 are usually the ones that ship, so it seems you're linking against the wrong dynamic library. – Edward Z. Yang Dec 18 '11 at 17:01
  • I actually just installed the one in the package manager. I suppose some setting somehow went wrong somewhere. I guess I'll just try reinstalling for now. – Cubic Dec 18 '11 at 18:14

1 Answers1

2

I got it fixed for now by just copying libffi.so.5 and renaming the copy to libffi.so.4 - kinda dirty hack, but as I am not planning on distributing binaries for now I don't really mind as long as it works. Though I would still prefer if someone was able to show me a better solution.

Cubic
  • 14,902
  • 5
  • 47
  • 92
  • 2
    In the same vein, you could just create a symbolic link instead of copying, i.e. ln -s /usr/lib/libffi.so.5 /usr/lib/libffi.so.4 – tmatth Aug 04 '12 at 12:10
  • At the time I was still pretty new to Ubuntu and didn't know this. Didn't have problems like this on the newer versions. – Cubic Aug 04 '12 at 18:54