Sunday, April 3, 2011

Howto: Install GHC 7.0.3 on OS X 64-bit with shared library support

I have JackOSX installed on my computer, which provides the JACK client libraries only as a dynamic library. I want to build Sonke Hahn and Henning Theilmann's Haskell bindings to the JACK library, but GHC doesn't come build with dynamic library support for OS X x86_64 in the Haskell Platform. I grabbed the GHC 7.0.3 sources and discovered the following steps to get a GHC install with dynamic library support. (You must have a working 64-bit GHC installed, I used 7.0.2 from HP 2011.2.)

  1. Install libgmp (I used Homebrew). Though the GHC sources include libgmp, it doesn't build libgmp as a shared library, which causes problems linking integer-gmp later on. Installing libgmp through homebrew or macports will build libgmp as a shared library.
  2. In the build tree, copy "mk/" to "mk/".
  3. Edit the "mk/" file, and find the line that says "PlatformSupportsSharedLibs = ..."
  4. In the platform list on this line, add "x86_64-apple-darwin"
  5. Run the configure script, making sure to use "--with-gmp-includes" and "--with-gmp-libraries" to tell configure where to find your preinstalled libgmp headers and libraries.
  6. make && sudo make install

Disclaimer: I take no responsibility for any damage caused by following these instructions. Building OS X 64 bit shared library code is obviously not officially supported by GHC, and I'm not sure it works for anything other than the simplest programs.

Edit: Don Stewart commented that a release of the Haskell Platform with support for dynamic libraries on OS X is due in early April 2011.