On 06/08/2009, at 6:11 PM, John Meacham wrote:
On Thu, Aug 06, 2009 at 05:22:06PM +1000, Mark Wotton wrote:
Is there a way to build dynamic libraries in jhc such they're linkable and callable from a C driver? I'm hoping to write a bridge between ruby and haskell, and GHC's dynamic lib support seems a bit sketchy currently.
If your interface is constrained to things expressible in the FFI spec, then you can 'foreign export' whatever functions you like from haskell then compile the resulting C file into a shared library. I don't have a specific option that does this automatically, but it should be easy to do by hand once you see the C file it produces. Let me know what issues you run into, if we can come up with a generally useful 'recipe' for creating shared libraries from haskell I'd like to add it as an explicit command line option to jhc.
Colour me shocked, if I just comment out the main function, the exported functions work fine. Thanks, this is really helpful. I'd like to see if other packages work as well - how do you enable extra libraries like containers? jhc --list-libraries shows that containers-0.2.0 is there, but when i try to compile a program with Data.Map calls in it, jhc complains bitterly: mwotton@ubuntu-vm:/mnt/hgfs/projects/rhaskell/linux$ jhc -v Test.hs reading /usr/local/etc/jhc-0.6/targets.ini reading /usr/local/etc/jhc-0.6/targets.ini jhc -v Test.hs jhc 0.6.1 (0.6.0-32) Compiling [Right "Test.hs"] Loading libraries: ["base","haskell98"] Library: base-1.0 </usr/local/share/jhc-0.6/base-1.0.hl> Library: haskell98-1.0 </usr/local/share/jhc-0.6/haskell98-1.0.hl> Test.hs:1 - Warning: The pragma 'LANGUAGE' is unknown Main [Test.hs] <Test.ho> Error: Module not found: Data.Map Thanks once again, I might actually get this project out the door soonish. Cheers Mark