#5101: GHC and GHCi use different syntax for dynamic libraries
--------------------------------+-------------------------------------------
Reporter: mcandre | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.0.3 | Keywords:
Testcase: | Blockedby:
Os: MacOS X | Blocking:
Architecture: x86 | Failure: Incorrect warning at
compile-time
--------------------------------+-------------------------------------------
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.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5101>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs