GHCi fails to load shared object (the 'impossible' happened)
I have a project that uses two external libraries, namely -lcrypt and -lpcre. Building with cabal and running the resulting executable works as expected, but I'm having trouble starting a REPL in GHCi:
% cabal repl
Preprocessing executable 'etamoo' for EtaMOO-0.2.1.0...
GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help
/usr/bin/ld: dist/build/etamoo/etamoo-tmp/src/cbits/crypt.o: relocation R_X86_64_PC32 against undefined symbol `crypt' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
The error suggests I need -fPIC, and this seems to help the -lcrypt case, but now I get:
% cabal repl --ghc-options="-fPIC"
Preprocessing executable 'etamoo' for EtaMOO-0.2.1.0...
GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.1 for x86_64-unknown-linux):
Loading temp shared object failed: /tmp/ghc21539_0/libghc21539_2.so: undefined symbol: pcre_callout
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
FYI the C type of pcre_callout is a little unusual:
extern int (*pcre_callout)(pcre_callout_block *);
In other words it is a global variable (pointer to function), not a function itself.
Any advice is welcome, including the proper way to start GHCi given these external dependencies, as well as on this apparent bug.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.10.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | hvr |
| Operating system | |
| Architecture | x86_64 (amd64) |