GHC 8.6 for macOS depends on homebrew
I guess the ghc-8.6.1-x86_64-apple-darwin.tar.xz is build with homebrew. So, it depends on homebrew's "libgmp".
Since I'm using MacPorts, the following error occurs on installation:
% sudo make install "utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" copy libraries/ghc-prim dist-install "strip" '' '/usr/local/ghc-8.6.1' '/usr/local/ghc-8.6.1/lib/ghc-8.6.1' '/usr/local/ghc-8.6.1/share/doc/ghc-8.6.1/html/libraries' 'v p dyn' dyld: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib Referenced from: /Users/kazu/Downloads/ghc-8.6.1/libraries/base/dist-install/build/libHSbase-22.214.171.124-ghc8.6.1.dylib Reason: image not found make: *** [install_packages] Abort trap: 6 make: *** [install] Error 2
After make a link from "/usr/local/opt/gmp/lib/libgmp.10.dylib" to "/opt/local/lib/libgmp.10.dylib" installed by MacPorts, the installation succeeds.
But when using GHC 8.6.1, the following error occurs:
[15 of 15] Compiling Network.DNS ( Network/DNS.hs, dist/build/Network/DNS.o ) ld: library not found for -lgmp clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) cab: callCommand: cabal build (exit 1): failed
To fix this, the following is necessary:
% export LIBRARY_PATH=/usr/lib:/opt/local/lib
- "/usr/lib" is for "libiconv" and should come first to hide "/opt/local/lib/libiconv"
- "/opt/local/lib" is for "libgmp"