Create a static Haskell Linux executable

后端 未结 3 1841
庸人自扰
庸人自扰 2020-12-23 17:46

It\'s not often two things I love so much come together to cause me so much annoyance (besides my kids). I\'ve written a Haskell program at work that uses libraries like tex

相关标签:
3条回答
  • 2020-12-23 18:05

    This simple example "works for me":

    $ cat A.hs
    main = print "yes"
    
    $ ghc -O2 --make -static -optc-static -optl-static A.hs -fvia-C -optl-pthread
    
    $ ldd A
        not a dynamic executable
    $ ./A
    "yes"
    

    (and I've used this process, via .cabal, to ship executables for clients in the past couple of years).

    I think the best bet is to file bugs, and get this working. The IHG can also fund work like this, but I'm fairly sure the GHC team would consider this a high priority, if you're trying to ship products.

    0 讨论(0)
  • 2020-12-23 18:07

    It is related to the old glibc library in CentOS. You have to compile with the same version of glibc as installed on CentOS.

    I had exactly the same problem. Haskell executable compiled on arch (or ubuntu) won't run on CentOS. In my case though i was lucky, because our admin just removed CentOS and installed Arch for application server.

    0 讨论(0)
  • 2020-12-23 18:20

    I found out the problem. It seems that the link to the Biohaskell page is accurate: this is a problem loading iconv. This occurs when calling openFile, but not when calling openBinaryFile. Since xml-enumerator uses the latter, it worked just fine. Switching over the rest of the code to use openBinaryFile instead (via Data.Enumerator.Binary.enumFile) got everything to work.

    This is a good workaround for my use case, but the bug still exists.

    0 讨论(0)
提交回复
热议问题