Haskell program built on Ubuntu 11.10 does not work on Ubuntu 10.04

I am trying to provide users of my program with some Linux executables in addition to current Windows, so I installed Ubuntu 11.10 (since the haskell platform package on 11.04 is still a 2010 version). However, when I try to run the resulting binary on Ubuntu 10.04, I get a message that it cannot find libgmp.so.10. Checking / usr / lib shows that 10.04 comes with libgmp.so.3, while 11.10 has libgmp.so.10. Therefore, it seems that the GHC is communicating with libgmp dynamically and not statically, which I thought was the default.

Is there a way to tell GHC to statically include libgmp in a binary? If not, is there another solution that does not require the user to install a different version of libgmp?

+4
source share
3 answers

It turns out that a static flag is not enough for static linking of a binary file. Use instead:

ghc -static -optl-static -optl-pthread --make yourfile.hs 

Using this, my binaries worked correctly in both versions of Ubuntu.

+2
source

Often older libgmp packages are also available; that is, make your program depend on the libgmp3c2 package instead of the generic libgmp or libgmp10. This can often be achieved by compiling with an earlier version of GHC or gmp lib (for example, install libgmp3-dev instead of libgmp10-dev).

+1
source

You have the ghc -static option for statically linking to libraries.

+1
source

All Articles