ghci and ld scripts

Duncan Coutts duncan.coutts at
Sun May 16 17:48:07 EDT 2004

So here's the problem:

We have a Haskell binding to a C library (one of the gtk extension libs)
which uses the pthread library. So we put "pthread" in the
extra_libraries section of our ghc package conf file.

This works fine when building standalone programs, however when we try
and use this package in ghci we get this error:

Loading package gtk2 ... linking ... done.
Loading package sourceview ... ghc-6.2.1: can't load .so/.DLL for:
pthread (/usr/lib/ invalid ELF header)

Inspecting /usr/lib/ we find that indeed it is not a .so
file but a gnu ld script:

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
GROUP ( /lib/ /usr/lib/libpthread_nonshared.a )

So we should get ghci to dynamically load /lib/, however
there is no way to specify this in the package.conf file.

It turns out that we don't need ghci to load this .so because it is a
dep of another .so that we do load, however if I leave it out then
building standalone progs would fail to link.

Has anyone come across this before? How do you deal with it?


More information about the Glasgow-haskell-users mailing list