How do I export Haskell-functions to C under Linux or Unix?
Robbert de Haan
Wed, 15 Aug 2001 16:09:49 +0200 (MEST)
I'm currently working on a project where it would save me a lot of time if
I could use the FFI's 'foreign export'-statement, enabling me to call
Haskell-functions from C. Unfortunately, I can't get it to work...
After reading about various tools and compilers and experimenting with
some, I came to the conclusion that the most (and perhaps only) viable
option would be to use HDirect in combination with the Glasgow Haskell
Compiler. But even the most simple example, exporting Int ->
Int-functions, (which doesn't even appear to use the HDirect library) just
When using ghc-4.08.2 everything compiles and links just fine, but when
running the result I get an 'Illegal instruction' error (RedHat Linux 7.1)
or a 'Segmentation Fault' under Solaris 8.
When using ghc-5.00.2 the object files are created, but I get the
following error when linking (using ghc-5.00.2 -fglasgow-exts -static
-no-hs-main -i../../lib -L../../lse -lhdirect -o tst tst.o libHStst.a,
see the HDirect server-example):
Undefined first referenced
symbol in file
ld: fatal: Symbol referencing errors. No output written to tst
Has anyone else succeeded in exporting Haskell-functions and using them in
C-modules under Linux or Unix? Any help would be appreciated!