Re: Undefined symbol error coming from shared, dynamic library.

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!
-db
On 9/10/11, Sergiy Nazarenko
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Sun, Sep 11, 2011 at 10:56, Captain Freako
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.)
The first is because GHC doesn't link its libraries using -L and basenames, but full path names. Since you used a basename, you also have to use -L to tell it how to expand the basename. The second is because those libraries are needed by libHSrts, and since you linked that explicitly you need to link its dependencies explicitly as well. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
participants (2)
-
Brandon Allbery
-
Captain Freako