how to generate static library with Haskell FFI?

206 views Asked by At

to compile a haskell library to use in C++ today I use stack ghc:

stack ghc -- -c -dynamic -fPIC -XHaskell2010 -XOverloadedStrings TestFFI.hs

stack ghc -- --make -dynamic -shared -fPIC -XHaskell2010 -XOverloadedStrings TestFFI.hs -o libTestFFI.so

gcc -fPIC -c test.c -I`stack ghc -- --print-libdir`/include

stack ghc --package Test -- -o libTest.so -shared -dynamic -fPIC TestFFI.o -lHSrts-ghc8.0.2 -lHStimezone-olson-0.1.7-Ib9s8yi63Kn858Rr44Ixqe-ghc8.0.2 test.o

It works, but it has a problem for deploy, when I use ldd command on generated library, all the path is pointing for my HOME folder, I would like to generate a static library, with static dependencies, to avoid install Haskell on the user system.

Ps: I will use Haskell library on C++ code, but Haskell FFI works only with C.

0

There are 0 answers