Compiling a haskell project as a shared library and loading it in C/C++

So I'm trying to follow [this blog][1]. So I tried the code, couldn't compile the haskell part, probably due to the fact the guide uses version 6, but I have version 7 of ghc. By changing the paramaters I could compile it with the following: ghc --make -dynamic -shared -fPIC -no-hs-main -optl '-shared' -optc '-DMODULE=Test' -o Test.so Test.hs module_init.c But the when trying to load it, on dlopen, I get the following error: /usr/lib/ghc/ghc-prim-0.2.0.0/libHSghc-prim-0.2.0.0-ghc7.4.1.so: undefined symbol: stg_forkOnzh I suspect it's because the haskell runtime is not linked to the shared library but adding -L/usr/lib/ghc/ didn't really help. I searched a lot, but couldn't find anymore example that somebody have done this. [Here's also some docs][2] for compiling shared libraries: [1]: http://weblog.haskell.cz/pivnik/building-a-shared-library-in-haskell [2]: http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/using-shared-libs.htm...

On 09/01/2012 12:13 AM, Farid Neshat wrote:
So I'm trying to follow [this blog][1]. So I tried the code, couldn't compile the haskell part, probably due to the fact the guide uses version 6, but I have version 7 of ghc. By changing the paramaters I could compile it with the following:
ghc --make -dynamic -shared -fPIC -no-hs-main -optl '-shared' -optc '-DMODULE=Test' -o Test.so Test.hs module_init.c
You need to link against the haskell runtime: ghc --make -dynamic -shared -fPIC -no-hs-main -o X.so -optl-Wl,-rpath,/usr/lib/ghc/ -lHSrts_debug-ghc7.4.1 Cheers, M
participants (2)
-
A.M.
-
Farid Neshat