ghc, FFI and autotools

Manuel M T Chakravarty chak at cse.unsw.edu.au
Sun Nov 23 21:54:58 EST 2003


Lloyd Allison <Lloyd.Allison at infotech.monash.edu.au> wrote,

> The next step, or "impasse" to give it the technical name, is to add
> 
>                        /functionsH.hs  -- Haskell called from functions.c
> 
> 
>  ? Please has anybody used ghc in this type of environment before, and
>  ? have advice on the exercise in general or on
>  ? creating a *shared library* from C + Haskell code in particular ?

GHC cannot produce shared libraries.  However, maybe you can
work around this in your case, as you - if I understand you
correctly - don't really want shared library code generated
by the Haskell compiler, but you want shared-library C code
that calls into Haskell.  All the Haskell code can be
statically linked, I assume.

Unfortunately, I can't give you a concrete recipe on how to
set this up, but it sounds as if it were possible.  However,
it seems to me as if one problem that you encountered was
that you didn't link GHC's standard libraries to your code.
More precisely, you will need to link GHC's runtime system
and the standard libraries statically with your Haskell
library.  Around this you can try to craft a layer of C
functions that can be dynamically linked.

Cheers,
Manuel


More information about the Haskell mailing list