Linking with dynamic libraries on OS X fails due to absolute path in libffi.dylib #27
Description
I ran into a problem compiling an executable using shared libraries. I am using OS X 10.8.5 with HP 2013.2.0.0 64 bit.
First I cabal installed a tiny one-module package with --enable-shared. Then I have a tiny executable that uses the module in this package, which I compiled with "ghc --make Main.hs -dynamic". Then when I run it I get:
dyld: Library not loaded: /Users/ian/zz64/ghc-7.6.3/libffi/build/inst/lib/libffi.6.dylib
Referenced from: /usr/local/lib/ghc-7.6.3/libHSrts-ghc7.6.3.dylib
Reason: image not found
Trace/BPT trap: 5
Turns out the dynamic library for the HSrts package in the HP refers to libffi with a hard-coded path to Ian's machine!
$ otool -L /usr/local/lib/ghc-7.6.3/libHSrts-ghc7.6.3.dylib
/usr/local/lib/ghc-7.6.3/libHSrts-ghc7.6.3.dylib:
/usr/local/lib/ghc-7.6.3/libHSrts-ghc7.6.3.dylib (compatibility version 0.0.0, current version 0.0.0)
/Users/ian/zz64/ghc-7.6.3/libffi/build/inst/lib/libffi.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
There is a file /usr/local/lib/ghc-7.6.3/libffi.dylib , but it too depends on Ian's path:
$ otool -L /usr/local/lib/ghc-7.6.3/libffi.dylib
/usr/local/lib/ghc-7.6.3/libffi.dylib:
/Users/ian/zz64/ghc-7.6.3/libffi/build/inst/lib/libffi.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)