Step 1 - Getting GTK
First, download the all-in-one bundle of gtk. At the moment of this writing, the version you need is 2.16, but it may change in the future. You will get a compressed file. Decompress it in a path without spaces (for instance: .../gtk), and add to your PATH environment variable the directory .../gtk/bin. You will need this directory in your PATH not only for the installation, but also for executing your gtk-based programs. Otherwise, you will need to copy all DLL's needed for your program in the folder where it is running.
I don't know why, but spaces will do your installation fail. Official documentation alerts of this. What surprised me was that the pkg-config (and all others in the gtk binaries directory) command still works, despite of the spaces. This should not confuse you.
Step 2 - MinGW
Search in your Haskell Platform folder the directory mingw/bin, and add it to your PATH environment variable. I think this step is only necessary for the installation, although I can not confirm it yet.
Step 3 - Build tools
The gtk package can not be installed directly, it needs another package to be installed first, and cabal-install is not able to figure that it is necessary. So, before the gtk package, we install the gtk2hs-buildtools package:
> cabal install gtk2hs-buildtools
Step 4 - Install GTK
And finally, we are ready to install gtk in the traditional way:
> cabal install gtk
It will take a large time. At least, it will take it for me.
Haskell Platform and gtk
Currently, there is a bug that prevents you to install gtk on the version 2011.2.0.0 of the Haskell Platform. You must use an older version of the platform (2010.2.0.0 works).
While using gtk you may found problems, bugs or, perhaps, you have a request for a new feature in the package. For these purposes, visit the Gtk2Hs bug tracker.
Another guides on this topic can be found at:
- Official guide: http://code.haskell.org/gtk2hs/INSTALL
- Mark Shroyer guide: http://markshroyer.com/2010/10/gtk2hs-on-windows
- Jacob Stanley guide: http://jystic.com/2010/10/20/installing-gtk2hs-on-windows
New notes (June 06, 2011)
I've tested the gtk installation with the Haskell Platform 2011.2.0.1 and it throws the same error (while cabal install gtk):
setup.exe: internal error: unexpected package db stack: [UserPackageDB]