Compiling packages for GHCi

Hi, I'm having problems using a package which links in foreign libraries from GHCi. I use a .cabal file to build the package and have the following option there: extra-libraries: stdc++ maxent z m gfortran m gcc_s After installation, it works fine when I compile code using that package. However, when I try it from GHCi I get: Loading package binary-0.3 ... linking ... done. Loading package filepath-1.0 ... linking ... done. Loading package haskell98 ... linking ... done. Loading package mtl-1.0.1 ... linking ... done. Loading package parsec-2.0 ... linking ... done. Loading package gramlab-lib-0.1 ... linking ... done. Loading package maxent-0.0 ... can't load .so/.DLL for: maxent (libmaxent.so: cannot open shared object file: No such file or directory) I don't have a libmaxent.so, the maxent library in at /usr/local/lib/libmaxent.a Can I somhow use my package with GHCi? Thanks!, Grzegorz

Grzegorz wrote:
Hi, I'm having problems using a package which links in foreign libraries from GHCi.
I use a .cabal file to build the package and have the following option there:
extra-libraries: stdc++ maxent z m gfortran m gcc_s
After installation, it works fine when I compile code using that package. However, when I try it from GHCi I get:
Loading package binary-0.3 ... linking ... done. Loading package filepath-1.0 ... linking ... done. Loading package haskell98 ... linking ... done. Loading package mtl-1.0.1 ... linking ... done. Loading package parsec-2.0 ... linking ... done. Loading package gramlab-lib-0.1 ... linking ... done. Loading package maxent-0.0 ... can't load .so/.DLL for: maxent (libmaxent.so: cannot open shared object file: No such file or directory)
I don't have a libmaxent.so, the maxent library in at /usr/local/lib/libmaxent.a
Can I somhow use my package with GHCi?
No, you need the .so. GHCi can't load static .a libraries. If you really have no way to get a .so, then it is possible to create a .o from the .a that GHCi can load using 'ld --whole-archive', but you're into hacker territory there. Cheers, Simon

On Jun 6, 2007, at 7:55 , Simon Marlow wrote:
Grzegorz wrote:
I don't have a libmaxent.so, the maxent library in at /usr/local/ lib/libmaxent.a Can I somhow use my package with GHCi?
No, you need the .so. GHCi can't load static .a libraries. If you really have no way to get a .so, then it is possible to create a .o from the .a that GHCi can load using 'ld --whole-archive', but you're into hacker territory there.
Alternately, just extract the contents of the .a into a subdirectory and explicitly load them: mkdir libmaxent cd libmaxent ar x /usr/local/lib/libmaxent.a cd .. ghci (...) libmaxent/*.o -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Brandon S. Allbery KF8NH
Alternately, just extract the contents of the .a into a subdirectory and explicitly load them:
mkdir libmaxent cd libmaxent ar x /usr/local/lib/libmaxent.a cd .. ghci (...) libmaxent/*.o
This doesn't quite work: ghc-6.6.1: libmaxent/trainer.o: unknown symbol `_ZNSt8ios_base4InitC1Ev' final link ... ghc-6.6.1: linking extra libraries/objects failed Thanks for the suggestion anyway! -- Grzegorz

Grzegorz wrote:
mkdir libmaxent cd libmaxent ar x /usr/local/lib/libmaxent.a cd .. ghci (...) libmaxent/*.o
This doesn't quite work: ghc-6.6.1: libmaxent/trainer.o: unknown symbol `_ZNSt8ios_base4InitC1Ev' final link ... ghc-6.6.1: linking extra libraries/objects failed
Looks like something from the C++ standard library is missing. You could try adding -lstdc++. (You would have stumbled into that anyway, even if GHC did read static libraries.) -Udo -- This is your brain. This is Perl. This is your brain on Perl. Any questions? -- Erik Naggum
participants (4)
-
Brandon S. Allbery KF8NH
-
Grzegorz
-
Simon Marlow
-
Udo Stenzel