Create a static Haskell Linux executable

99封情书 提交于 2019-11-29 21:30:17

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.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!