Tuesday, March 22, 2011

On Windows: How to install GTK

Sometimes, we look for provide a graphic interface to our programs, and, after analyze various options, we decide to use gtk. However, type cabal install gtk will not be enough to have installed the library. As various problems can arise during the installation, I decided to write this little step-to-step guide available for everyone interested.

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

Reporting problems

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.

Final notes

Another guides on this topic can be found at:
I tried to merge everything I have read, and my own experience, filtering the necessary information to get gtk working. I hope it helps.

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

Registering glib-0.12.0(cairo-0.12.0)...
setup.exe: internal error: unexpected package db stack: [UserPackageDB]

Monday, March 21, 2011

Blog created

I have decided to create a blog where write my own experiences and thoughts.

As soon as I have any idea, I will post it here, without excesive rigor. This will help me to arrange ideas and share them.

This blog will focus mainly on functional programming with Haskell, although it may arise also some mathematical threads.

For all those who read me, welcome!