in Software

Getting Cabal to run on Mac OS X Leopard

In preparation for the work on my Haskell NXT Library, I needed to install Yampa today. The official page lists version 0.9.1 as most recent, though that release is from 2002. Newer (though kinda "inofficial") versions are available through Hackage/Cabal. Getting Cabal to work wasn't difficult at all in the end, but scraping together all the information on how to get there was a bit tricky for an absolute n00b like me. I publish my steps here so that others trying to get Cabal to run on Leopard (or other systems) can save some time.

First, you should have GHC installed via MacPorts (sudo port install ghc)

I installed darcs too, but I don't even think that was necessary (sudo port install darcs)

Now, the most recent Cabal Library (the one included in MacPorts GHC was a bit outdated):
Go to, download and untar the most recent Cabal (library) and cabal-install (commandline interface) packages. Install Cabal as root, as described in the readme-file:

ghc --make Setup.hs
./Setup configure
./Setup build
sudo ./Setup install

For cabal-install to compile, we need to further libraries, HTTP and zlib, both obtainable in the HackageDB (just follow the links). Download and untar, then proceed as with Cabal:

ghc --make Setup.lhs (.lhs in case of HTTP, zlib uses the .hs extension)
./Setup configure
./Setup build
sudo ./Setup install

Finally change to the cabal-install directory and repeat these steps again.

After cabal-install is installed, run cabal update to obtain the latest package list. Now you can install packages via cabal install <package name>

Write a Comment



  1. When trying to install zlib, I get this error:

    $ sudo ./Setup build
    Preprocessing library zlib-…
    ld: library not found for -lgmp
    collect2: ld returned 1 exit status
    linking dist/build/Codec/Compression/Zlib/Stream_hsc_make.o failed
    command was: /usr/bin/gcc -lz -L/sw/lib/ghc-6.8.3/lib/bytestring- -L/sw/lib/ghc-6.8.3/lib/array- -L/sw/lib/ghc-6.8.3/lib/base- -L/sw/lib/ghc-6.8.3 -lm -lgmp -ldl dist/build/Codec/Compression/Zlib/Stream_hsc_make.o -o dist/build/Codec/Compression/Zlib/Stream_hsc_make

    Do you know what ” -lgmp” means, or what I should look for?

  2. Your system is missing the library gmp (libgmp.a, the GNU multiprecision library). Install it via your system’s package manager or manually (use Google).

    Then the build should succeed.

  3. I installed gmp through fink…

    $ fink list -i gmp
    i gmp 4.2.4-1000 GNU multiple precision arithmetic library
    i gmp-shlibs 4.2.4-1000 Shared library for gmp package
    i libgmpxx-shlibs 4.2.4-1000 Shared C++ library for gmp package

    $ ls /sw/lib/libgmp*
    /sw/lib/libgmp.3.4.4.dylib /sw/lib/libgmpxx.4.0.4.dylib
    /sw/lib/libgmp.3.dylib /sw/lib/libgmpxx.4.dylib
    /sw/lib/libgmp.a /sw/lib/libgmpxx.a
    /sw/lib/libgmp.dylib /sw/lib/libgmpxx.dylib
    /sw/lib/ /sw/lib/

    But I’m getting the same error. Could it be that gcc is called from /usr/bin? Do I need to tell the compiler how to use -lgmp somehow?

    (thanks for the feedback)

  4. Try adding a -L/sw/lib option somewhere. That should tell the compiler to search that directory for libs too. But I’m really not an expert on neither gcc nor Haskell, far from it.

  5. There’s probably a more proper way to do this, but here’s what worked. I created a bash script with this in it:


    export LIBRARY_PATH=/sw/lib:$LIBRARY_PATH
    ./Setup build

    And then I ran

    $ sudo ./

    That compiled zlib without complaining! Unfortunately cabal-install is still giving me the error:

    $ ./Setup configure
    Configuring cabal-install-0.6.2…
    Setup: At least the following dependencies are missing:
    zlib >=0.4 && <0.6

    And as far as I can tell, I just compiled zlib! Ugh.

  6. Okay, now I tried running the cabal-install ./, and that installed everything as expected.

  7. Hi, thanks for these instructions.

    Everything seems to work fine, but when I run cabal update I get the following error:

    wlan-n124-20:Desktop dmorti$ cabal update
    Config file /Users/dmorti/.cabal/config not found.
    Writing default configuration to /Users/dmorti/.cabal/config
    Downloading the latest package list from
    cabal: user error (Codec.Compression.Zlib: premature end of compressed stream)

    Any idea what’s going on here? I found some mention of this problem occurring for windows users, but nothing about OSX…??


  8. Thanks for this instruction. Before I try this experiment a question – is this also going to work on Snow Leopard, the OS on the Mac after Leopard. I suspect not…. Cheers!

  9. Honestly, I have no idea but why wouldn’t it work?
    Maybe you have to set an ARCHFLAG= x86_64 before compiling.

  10. Hi, I am no computer software developer but I really want to play Cabal on Mac OS. I have OS X Lion. Just wondering if you can reiterate the steps in “English” terms to aid me. Cheers