Installing on Windows

Instructions for installing on Windows

  1. Make sure you have GHC 6.6.1 installed. This exact version of GHC is required. If you cannot install either version of GHC you can either use an older version of Gtk2Hs (eg 0.9.11 worked with GHC-6.4.2 and 6.6) or build from source with any supported version of GHC.
  2. download and run the Gtk2Hs installer gtk2hs-0.9.12.exe
  3. you can select to install the demo source code and the API documentation

You’re done! You will now be able to compile and run Haskell programs that use Gtk2Hs.

Quick-start Guide

You might like to start by compiling some of the demo programs in the demos folder. For example to compile the noughts and crosses demo, open a console window, change directory to the noughty folder and use ghc --make to compile the demo:

cd "C:\Program Files\Gtk2Hs\demos\noughty"
ghc --make Noughty.hs

This produces Noughty.exe in the same folder (or main.exe if you’re using GHC 6.4.2). When you run this .exe it pops up a console window; you can read about how to stop that happening.

Note that GHCi support is available in this release.

23 Responses to “Installing on Windows”

  1. andrew frank Says:

    i inquire about support for ghci - is there a workaround (eg. duplicating files or similar) for the window system?

    thank you

  2. emil Says:

    I have installed on windows XP latest GTK i.e. gtk-win32-devel-2.8.14-rc1.exe,
    also GHC 6.4.1,
    and gtk2hs-0.9.10.exe

    after compiling demos, I have received next mesage - linking error:

    “The procedure entry point gdk:cairo_create dould not be located in the dynamic link library libgdk-win32-2.0-0.dll”

    That dll is on PATH, of course.

  3. Duncan Says:

    emil: that’s an interestng error. cairo_create is not exported from libgdk-win32-2.0-0.dll

    I’ll try installing that version of Gtk+ on my windows machine.

    It may be better to continue this conversation on the gtk2hs-users mailing list.

  4. MartyG Says:


    I had a similiar problem, but a quick search of my drives showed that there were other applications on my path that had a copy of the libgdk-win32-2.0.0.dll that do not have the cairo functions. Once I corrected the search order of my Path variable to pickup the GTK version first, everythong worked fine


  5. Dmitry V'yal Says:

    The hyperlink “build from source” in step 1 doesn’t work.

  6. Duncan Says:

    Thanks Dmitry. Fixed.

  7. Justin Says:

    I installed 6.4.1 (I also have 6.4.2). I changed my system Path on windows to include the ghc bin folder C:\ghc-6.4.1\bin

    from a command line I get

    $ ghc –version
    The Glorious Glasgow Haskell Compilation System, version 6.4.1

    but when I run the windows installer it says please install ghc 6.4.1

    Where does it look?


  8. Justin Says:

    Sorry it just fixed itself ;-)

  9. Justin Says:

    Very sorry, no it didn’t. I was installing ghc again. :-(

  10. Duncan Says:

    Hia Justin, the installer first looks on the path and then in the registry for keys that the ghc installer sets. So it should work if you used the installer, or if you built it yourself then it should work if you set your path appropriately.

    If it’s still not working, post to the gtk2hs users list with all the details and we can try and work it out.

  11. Anna Says:

    I’m receiving the error “The GTK+ libraries are not on the windows search path! …Please reinstall Gtk+ and make sure the “register environment variables” option is selected”. After following that single piece of advice, I’m still getting the error. Please help. (I’m a student taking functional programming and might not know how to do anything very complicated).

    Help is much appreciated!!!!!

  12. Zellyn Says:

    C:\Program Files\Gtk2Hs\demos\noughty>ghc –version
    The Glorious Glasgow Haskell Compilation System, version 6.6

    C:\Program Files\Gtk2Hs\demos\noughty>ghc –make Noughty.hs

    Could not find module `Graphics.UI.Gtk’:
    Use -v to see a list of the files searched for.

  13. Zellyn Says:

    Thanks for the update - it works now!

  14. Duncan Says:

    Yeah, oops, sorry about that :-)

  15. clem Says:

    I tried to install the windows version, and the installer complains that my existing gtk stuff will be found first in my path. It suggests removing that stuff (not an option) or .. and then it overruns the text box and the scroll bar goes no further so i cannot read the suggested fix. can you tell me where to put your dlls or what to add to my path?

  16. Duncan Says:

    Hi clem,

    Basically when you run a prog you’ve compiled using the Gtk2Hs lib, that prog needs to be able to find the various Gtk+ .dlls.

    If we were distributing a stand alone .exe this would be easy as we’d just put the .exe in the same directory as all the Gtk+ dlls. Indeed you can do this too and it’ll work fine, however it’s not the normal way we expect things to work with GHC. We expect to be able to build a .exe in any directory and have that .exe work without having to move it into a special directory first.

    So our current solution is to put the directory containing the Gtk+ dlls into the %PATH% environment variable so that they will be found when you run the .exe you’ve built. For that to work, the Gtk+ ‘bin’ directory has to appear in the %PATH% list before any other directories that might have dlls with the same names.

    However if you have another Gtk+ installation that you need to keep in the %PATH% to make some other app work then we have a problem. There are a couple solutions:

    1. It might be that the two are compatible. Gtk+ is supposed to be backwards compatible, so having the later version of the Gtk+ dlls appear first in the path may allow both Gtk2Hs progs and your other Gtk+ program(s) to work. It’s worth a go at least. To do that, right click on “My Computer” and select “Properties”. On the “Advanced” tab select the “Environment Variables” button. In the “System Variables” section, edit the “Path” variable and edit so that the Gtk2Hs “bin” directory appears before the similar one for your other Gtk+ installation. Then test if your other Gtk+ app still works. If not, revert your change to the Path variable and try option 2:

    2. We could do what Visual Studio does and provide a batch file that sets up a special command line environment to use when developing and running Gtk2Hs programs. This would set Gtk2Hs’s installation of Gtk+ to appear first in the %PATH%, but only for that command line session - not globally for the whole desktop. You can get this effect by doing the following:

    open a command console and run the command:
    set PATH=C:\Program Files\Gtk2Hs\bin;%PATH%

    You should then be able to compile and run Gtk2Hs program fine, though only from that console session.

    Hope this helps!

  17. Philippa Says:

    Any chance of a version of the installer that comes with SourceEdit (and I guess the other two options that work)? How much bigger would the build be?

  18. Duncan Says:

    Philippa, I think it weighs in at around 15-20Mb rather than 10Mb.

  19. Philippa Says:

    I know I’d be plenty willing to deal with an installer that size if it doesn’t cause too big a problem on your end.

  20. DLL Files Gal Says:

    Thanks for the breakdown.. tons of good info.

    Bookmarked this page for future reading.

    Sash Geran

  21. Mike Says:

    Hey man i followed the directions and got an error that says

    “please install ghc 6.4.1″

    After googling that error … i get nothing that makes sense?

    Any clue?


  22. Duncan Says:

    Mike, are you sure you’re running the 0.9.12 installer? It asks for ghc 6.6.1. I just checked the current installer and it doesn’t mention ghc 6.4.1 anywhere.
    Was that the full error message or was there more detail than that?

  23. evan Says:

    I’m able to compile the demo programs from the cmd line in Win XP, but I get a linking error for “package glib…” when I try to load the same demo programs in GHCi.