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/build.mk.sample" to "mk/build.mk".
  3. Edit the "mk/config.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.

3 comments:

  1. Note that a revision of the Haskell Platform to include new support for dynamic libs on Mac OSX is due in early April 2011.

    ReplyDelete
  2. Does that include support for shared libraries under x86_64 OS X?

    ReplyDelete
  3. Also, since Cabal won't build just a dynamic library, this didn't actually solve my problem.

    ReplyDelete

Comments are moderated. I will try to get to them quickly. Off-topic or obscene comments, name-calling, and destructive criticism will all vanish into the void.

Disagree with me all you want, but keep it respectful towards me and everyone else.