Undefined symbol error coming from shared, dynamic library.

Captain Freako capn.freako at gmail.com
Sun Sep 11 16:56:44 CEST 2011

Sergiy, Tom,

Thanks for your replies.

Sergiy, I was able to get this working without having to recompile my
installed Haskell libraries.

Tom, you were correct; I needed to explicitly link against the Haskell
run-time system, as well as a few other things:

I changed my ghc link options from this:

HC_LOPTS = -no-hs-main -shared -package parsec -package dsp -static

to this:

HC_LOPTS = -shared -dynamic -package parsec-3.1.1 -package dsp -lHSrts
-L/usr/lib/ghc-6.12.3/ -lm -lffi -lrt

and things are working.

(The command that builds my mixed language, shared object library,
`libami.so', is:

ghc -o libami.so $(HC_LOPTS) {object files, compiled from both C and Haskell}

I can understand why I'd have to explicitly link against `libHSrts',
since I'm asking ghc for a shared object library and not an
executable. However, I'm not sure about the following:
- Why do I need to give the `-L/usr/lib/ghc-6.12.3/' option? (It seems
like ghc ought to know about that, implicitly.)
- Why do I need to explicitly link against the 3 standard C libraries:
`m', `ffi', and `rt'? (I've never needed to do this, previously, when
I was building/testing this project statically.)

Thanks, in advance, for any insights!


On 9/10/11, Sergiy Nazarenko <nazarenko.sergiy at gmail.com> wrote:
> I've recompiled my library again and now it works without any problem.
> Probably I made mistake somewhere.
> Cheers,
> Sergiy
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Glasgow-haskell-users mailing list