Mon, 9 Sep 2002 17:12:50 +0100
> (adding the linker flags to ld_opts does not make a
> difference for the rest of the story)
> To make everything work with ghc, I do the following:
> * gcc -c foo.c -o foo.o
> * ghc -c Foo.hs -o Foo.o
> * ar -rsv libHSFoo.a foo.o Foo.o
> Now, I can compile programs with "ghc -package foo". Great!
> However, when I try ghci, it does not work. So, first, I
> make a .o version of libHSFoo.a:
> * gld -r --whole-archive -o HSFoo.o libHSFoo.a
> But, when I start "ghci -package foo", it does not find the
> library libbar! It does not even find it when I say "ghci
> -L/path/to/libs -lbar -package foo"!
You should add "bar" to the 'extra_libraries' field of the package
config, because otherwise GHCi doesn't know about the dependency.
> No worries, we can make ghci read a .so file instead:
> * rm HSFoo.o
> * gcc -shared Foo.o foo.o -L/path/to/libs -lbar -o libHSFoo.so
> Starting ghci now loads libHSFoo.so, and everything works
I'm highly surprised if this really works. Can you actually call
functions from the Foo module without it crashing?