creating a library from haskell files and a c wrapper in Linux
I'm trying to create a (dynamic) library from a bunch of Haskell modules and some C code that calls functions exported from Haskell via the FFI. The problem is that I don't know how to link everything into a library. The first problem I had was that DLL_IMPORT which was found in some header files is undefined in Linux, so I just passed -DDLL_IMPORT= to gcc. The next problem is that I can't get ghc to make a library file for me, the --mk-dll flag just makes ghc output nothing, and I can find no other flag to make ghc create a library instead of a binary. I'll try to find out the right libraries to pass to ld, but it would be much easier if ghc could do it by itself, as it can do under Windows. Regards, Martin -- Martin Norbäck d95mback@dtek.chalmers.se Kapplandsgatan 40 +46 (0)708 26 33 60 S-414 78 GÖTEBORG http://www.dtek.chalmers.se/~d95mback/ SWEDEN OpenPGP ID: 3FA8580B
tis 2002-09-10 klockan 15.40 skrev Martin Norbäck:
I'll try to find out the right libraries to pass to ld, but it would be much easier if ghc could do it by itself, as it can do under Windows.
Now I have done the following: # ghc -fglasgow-exts -c Adder.hs # gcc -c -DDLL_IMPORT= -I/usr/lib/ghc-5.04/include dllMain.c # ld -shared -o adder.so Adder.o Adder_stub.o dllMain.o -L/usr/lib/ghc-5.04 -lHSbase -lHSbase_cbits -lHSrts -lHSbase -lgmp # gcc test.c -L. -ladder # env LD_LIBRARY_PATH=. ./a.out and then I get the following: a.out: fatal error: LOOKS_LIKE_GHC_INFO- is incorrectly defined What to do next, I wonder... Regards, Martin -- Martin Norbäck d95mback@dtek.chalmers.se Kapplandsgatan 40 +46 (0)708 26 33 60 S-414 78 GÖTEBORG http://www.dtek.chalmers.se/~d95mback/ SWEDEN OpenPGP ID: 3FA8580B
tis 2002-09-10 klockan 16.08 skrev Martin Norbäck:
Now I have done the following:
# ghc -fglasgow-exts -c Adder.hs # gcc -c -DDLL_IMPORT= -I/usr/lib/ghc-5.04/include dllMain.c # ld -shared -o adder.so Adder.o Adder_stub.o dllMain.o -L/usr/lib/ghc-5.04 -lHSbase -lHSbase_cbits -lHSrts -lHSbase -lgmp # gcc test.c -L. -ladder # env LD_LIBRARY_PATH=. ./a.out
and then I get the following:
a.out: fatal error: LOOKS_LIKE_GHC_INFO- is incorrectly defined
What to do next, I wonder...
Here are the files used so you can test for yourself. Oh, and adder.so above should be libadder.so. -- Martin Norbäck d95mback@dtek.chalmers.se Kapplandsgatan 40 +46 (0)708 26 33 60 S-414 78 GÖTEBORG http://www.dtek.chalmers.se/~d95mback/ SWEDEN OpenPGP ID: 3FA8580B
participants (1)
-
Martin Norbäck