Hello,
I recently tried to build ghc on OS X Snow Leopard as 64-bit with shared library support. I had to self-compile gmp and modify mk/build.mk (I later saw that Edward Amsden blogged about the same experience, http://blog.edwardamsden.com/2011/04/howto-install-ghc-703-on-os-x-64-bit.html), and it seemed to work, but executables don't run. For example, with this small program:
> import qualified Data.Vector.Unboxed as V
> main = let vec = V.replicate 10 (1 :: Int) in print $ V.sum vec
I get this result:
Mac-1:~ johnlato$ ghc -O -dynamic foo.hs
[1 of 1] Compiling Main ( foo.hs, foo.o )
Linking foo ...
Mac-1:~ johnlato$ ./foo
dyld: Library not loaded: /private/var/folders/aJ/aJF0t1uBF7WDCz1PZV0A0U+++TI/-Tmp-/vector-0.7.0.176669/vector-0.7.0.1/dist/build/libHSvector-0.7.0.1-ghc7.0.3.dylib
Referenced from: /Users/johnlato/./foo
Reason: image not found
Trace/BPT trap
It seems that dyld is looking into build folders for the libraries. If I set DYLD_LIBRARY_PATH before compiling it appears to work:
Mac-1:~ johnlato$ export DYLD_LIBRARY_PATH=~/.cabal/lib/vector-0.7.0.1/ghc-7.0.3/:~/.cabal/lib/primitive-0.3.1/ghc-7.0.3/
Mac-1:~ johnlato$ ghc -O -dynamic foo.hs [1 of 1] Compiling Main ( foo.hs, foo.o )
Linking foo ...
Mac-1:~ johnlato$ ./foo
10
This seems to be required for any libraries I've installed via cabal-install --user, which quickly becomes onerous.
Could anyone give me some advice on how to make this work properly (e.g. without manually setting DYLD_LIBRARY_PATH)?
Thanks,
John