RE: creating a library from haskell files and a c wrapper in Linux
I want to make a library that can be used to link against from C code.
This library contains Haskell code, and I've made some C code to interface with the Haskell code, using startupHaskell and shutDownHaskell.
I want to make a self-contained library (which will contain the Haskell run-time code, the Haskell code, and the C interface code) that I can link to without having to use ghc to link. I also would like to make this library dynamic so that I can dlopen it later.
When I link the .o files with to produce an executable (with gcc) everything works fine. I get a binary that does what it should.
I don't see the reason why I shouldn't be able to link dynamically against the same .o files when they are in a dynamic library.
And whatever the reason is, how much work do you think it will take to fix it? And how easy is it?
It's not easy, I'm afraid. The ELF dynamic linking mechanism is rather arcane and imposes a very C-like view of things on object files. Last time I looked into this, I concluded that it couldn't be done without sacrificing some of GHC's low-level optimisations (specifically, placing code next to data), and even then it would still be a lot of work. However, I've been surprised before by what dynamic linkers can do, so it might be worth looking into again. Anwyay, take a look through the archives of this list for more details. Cheers, Simon
participants (1)
-
Simon Marlow