[Haskell-cafe] Re: Exporting Haskell Libraries to C Programmers

Claude Heiland-Allen claudiusmaximus at goto10.org
Wed Mar 5 05:01:33 EST 2008

Bruce, Joseph R (Joe) wrote:
> I hadn't looked at CABAL before.  It's a very useful tool and met all my library-forming needs.
> That's only half my problem though.  I'm trying to make the use of this Haskell code as transparent as possible to the C programmers on the team.  Telling them about the Haskell base libraries dependency or distributing those libraries with my code is not too bad, but the list of -u flags that the linker needs is brutal.  Is there a way to avoid it, or embed it in the package?
> Ex (using ghc-6.8.2 -v):
> ...
> gcc -v -o primes Primes.o ./Primes_stub.o hs_primes_wrapper.o cprimes.c 


Maybe try compiling cprimes.c to cprimes.o with gcc, then link with GHC?

Something like:

gcc -o cprimes.o -c cprimes.c
ghc -no-hs-main --make -c *.hs
ghc -no-hs-main -package foo -o moo *.o

I know this isn't ideal, but it's similar to what I used to build a .so 
from Haskell code that can be loaded by a C app ignorant of Haskell.


More information about the Haskell-Cafe mailing list