Search code examples
linuxhaskellubuntughcstatic-linking

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?


Solution

  • 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.