FalconNL
FalconNL

Reputation: 1613

Haskell program built on Ubuntu 11.10 doesn't run on Ubuntu 10.04

I'm trying to provide the users of my program with some Linux binaries in addition to the current Windows ones, so I installed Ubuntu 11.10 (since the haskell-platform package on 11.04 is still the 2010 version). When I try to run the resulting binary on Ubuntu 10.04, however, I get the message that it cannot find libgmp.so.10. Checking /usr/lib reveals that 10.04 comes with libgmp.so.3 whereas 11.10 has libgmp.so.10. It would appear therefore that GHC is linking to libgmp dynamically rather than statically, which I thought was the default.

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

Upvotes: 4

Views: 1350

Answers (3)

Zhen
Zhen

Reputation: 4283

You have the ghc option -static to link statically against the libraries.

Upvotes: 1

FalconNL
FalconNL

Reputation: 1613

It turns out that in order to statically link the binary the -static flag is not sufficient. Instead, use:

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

Using this, my binaries ran correctly on both versions of Ubuntu.

Upvotes: 2

thiton
thiton

Reputation: 36049

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

Upvotes: 1

Related Questions