ghc 7.4.1 not producing stub.o files

2019-02-22 03:05发布

问题:

I'm running the default installation of Haskell platform on Ubuntu and when I run this example http://www.haskell.org/haskellwiki/Calling_Haskell_from_C "ghc -c -O Safe.hs" is not producing the Safe_stub.o file. I have checked this on a separate installation of Ubuntu on a friends box and on both 32 bit and 64 bit Ubuntu installs.

Can somebody confirm if this is specific to ghc-7.4.1 or Ubuntu installs only?

Thanks!

回答1:

It's a ghc-7.4 (ghc >= 7.2 actually) thing. That doesn't need and produce *_stub.o (or *_stub.c) files anymore. However, the command line for the final compilation has to change

$ ghc -no-hs-main -optc-O test.c Safe.o  -o test

You have to tell GHC that the main is not a haskell call.