ghc, FFI and autotools
Lloyd Allison
Lloyd.Allison at infotech.monash.edu.au
Tue Nov 25 15:39:58 EST 2003
It sounds plausible to have shared-library C-code that is
statically linked to Haskell code but it also sounds as if
there could be subtle (beyond me), important distinctions here?
Our local who knows most about autotools typically manages
to remove (define) one of the undef' Haskell library labels
and then another one replaces it.
A typical (not working) effort is here...
http://www.csse.monash.edu.au/~lloyd/tildeProgLang/Gnumeric/latest/haskell/
the problem area is what should be done in Makefile.am around about
...
$(LIBTOOL) --mode=compile $(HSCOMPILE) $(INCLUDES) -c $< -o $@
$(HSCOMPILE) -DPIC $(INCLUDES) -c $< -o $@
...
A gnu'eric plugin gets dynamically loaded, as I
understand it, when a particular one is required.
Lloyd
--
Lloyd ALLISON, CSSE, Monash University, Victoria, Australia 3800.
web: http://www.csse.monash.edu.au/~lloyd/ tel: +61 3 9905 5205
use: http://www.linux.org/ OpenOffice: http://www.openoffice.org/
On Sun, Nov 23, 2003 at 09:54:58PM +1100, Manuel M T Chakravarty wrote:
> 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