GHC and GHCi use different syntax for dynamic libraries
Loading libcharm.dylib into GHCi works as follows:
$ ghci -lcharm
GHCi, version 7.0.2: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Loading object (dynamic) charm ... done
final link ... done
Prelude>
-lcharm works for GCC, too.
$ gcc -o hellocharm.c -lcharm
But not GHC.
$ ghc --make -fforce-recomp -o hellocharm hellocharm.hs charm.hs -lcharm
[1 of 2] Compiling Charm ( Charm.hs, Charm.o )
[2 of 2] Compiling Main ( hellocharm.hs, hellocharm.o )
Linking hellocharm ...
ld: library not found for -lcharm
collect2: ld returned 1 exit status
make: *** [hellocharm] Error 1
Inexplicably, a different flag must be used: -dylib-install-name flag must be used instead.
$ ghc --make -fforce-recomp -o hellocharm hellocharm.hs charm.hs charm.c -I/usr/include -dylib-install-name /usr/lib/libcharm.dynlib
[1 of 2] Compiling Charm ( charm.hs, charm.o )
[2 of 2] Compiling Main ( hellocharm.hs, hellocharm.o )
Linking hellocharm ...
Why the weird syntax? It seems that in this regard, GHCi is actually closer to GCC syntax than GHC.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.0.3 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | x86 |