creating a library from haskell files and a c wrapper in Linux

Martin Norbäck
10 Sep 2002 17:32:38 +0200

Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

tis 2002-09-10 klockan 16.39 skrev Simon Marlow:
> > tis 2002-09-10 klockan 16.08 skrev Martin Norb=E4ck:
> > > Now I have done the following:
> > >=20
> > > # ghc -fglasgow-exts -c Adder.hs
> > > # gcc -c -DDLL_IMPORT=3D -I/usr/lib/ghc-5.04/include dllMain.c
> > > # ld -shared -o Adder.o Adder_stub.o dllMain.o
> > > -L/usr/lib/ghc-5.04 -lHSbase -lHSbase_cbits -lHSrts -lHSbase -lgmp
> > > # gcc test.c -L. -ladder
> > > # env LD_LIBRARY_PATH=3D. ./a.out
> > >=20
> > > and then I get the following:
> > >=20
> > > a.out: fatal error: LOOKS_LIKE_GHC_INFO- is incorrectly defined
> > >=20
> > > What to do next, I wonder...
> >=20
> > Here are the files used so you can test for yourself. Oh, and
> > above should be
> You can't make a dynamic library containing Haskell code on Unix, sorry. =
 What actually is it you're trying to do?

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

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?



Martin Norb=E4ck             =20
Kapplandsgatan 40       +46 (0)708 26 33 60                   =20
S-414 78  G=D6TEBORG
SWEDEN                  OpenPGP ID: 3FA8580B

Content-Type: application/pgp-signature; name=signature.asc

Version: GnuPG v1.0.6 (GNU/Linux)
Comment: För information se