Detailed instructions

Install gtk, cairo, etc. from MacPorts like this (note that the +universal is needed; if you already installed gtk or one of its dependencies, it is recommended you reinstall those as detailed in the NB at the end of this section).

sudo port install gtk +universal

go to the directory where gtk2hs is untarred and run

./configure --disable-split-objs --disable-gio

make

sudo make install

Alternatively, if you wish to follow the Mac OS X style of directory layout, you can use this configure command instead:

Where username is your username ofcourse. Right now you should be able to run the demos. Unfortunately, to build any libraries depending on gtk2hs, such as Chart, you need to edit one more file. You will need to find "package.conf" for your ghc by doing

ghc-pkg list

In the output you will see the full directory to your package.conf file. In this file, you need to search for "gthread", and everywhere you can find it, add "/opt/local/lib" (with quotes) to the libraryDirs array before it.

If all went well, it should be properly installed now.

NB: If compiling fails with architecture errors for certain dynlibs, you need to reinstall the packages these dynlibs belong to with +universal by doing

Edit /opt/local/macports/variants.conf and add +universal to the end of this file

sudo port selfupdate

sudo port sync

sudo port upgrade --force installed

GTK+ OS X Framework

This explains how to install Gtk2Hs on Macs using the native GTK+ OS X Framework, a port of GTK+ to the Mac that does not depend on X11, and hence, is better integrated into the Mac desktop - i.e., menus actually appear in the menu bar, where they belong. It also avoids the often tedious installation of GTK+ via MacPorts. However, it misses support for optional Gtk2Hs packages that are currently not supported by the GTK+ OS X Framework, most notably support for Glade. It does include support for Cairo, though.