These instructions are an update of the HomeBrew installation shown below (2008) for Mavericks. Make sure that the system you are using has the 64bit version of the Haskell platform installed. Unfortunately, if you have an older 32bit version these instructions will work but all the programs using gtk will fail to compile.

+

+

1. Install XQuartz ([http://xquartz.macosforge.org/landing/ download]) at the time these instruction were written version 2.7.5 worked.

* 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).

+

* Install gtk, cairo, etc. from MacPorts like this (note that the <tt>+universal</tt> 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

+

<pre>sudo port install gtk +universal</pre>

−

* go to the directory where gtk2hs is untarred and run

+

* Go to the directory where gtk2hs is untarred and run

−

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

+

<pre>./configure --disable-split-objs --disable-gio

−

:::make

+

make

−

:::sudo make install

+

sudo make install</pre>

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

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 [http://hackage.haskell.org/package/Chart/ Chart], you need to edit one more file. You will need to find "package.conf" for your ghc by doing

+

Right now you should be able to run the demos. Unfortunately, to build any libraries depending on Gtk2Hs, such as [http://hackage.haskell.org/package/Chart/ Chart], you need to edit one more file. You will need to find <tt>package.conf</tt> for your installed GHC by running

−

:::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.

+

<pre>ghc-pkg list</pre>

+

+

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

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

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

+

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

Alternatively, and this is recommended, you can follow the steps on [http://passingcuriosity.com/2009/haskell-on-snow-leopard/ Haskell On Snow Leopard Blogpost] to immediately add the universal variant of each package:

Alternatively, and this is recommended, you can follow the steps on [http://passingcuriosity.com/2009/haskell-on-snow-leopard/ Haskell On Snow Leopard Blogpost] to immediately add the universal variant of each package:

−

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

+

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

2 HomeBrew OS X Mavericks (64 bit, last checked 2014-05)

These instructions are an update of the HomeBrew installation shown below (2008) for Mavericks. Make sure that the system you are using has the 64bit version of the Haskell platform installed. Unfortunately, if you have an older 32bit version these instructions will work but all the programs using gtk will fail to compile.

1. Install XQuartz (download) at the time these instruction were written version 2.7.5 worked.
Make sure to logout and login again.

5.1 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:

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 installed GHC by running

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

6 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.