Gtk2Hs/Windows

From HaskellWiki

Please read and update Gtk2Hs/Installation instead.

Windows 7 32 bit[edit]

Changing Environment Variables[edit]

This installation process involves adding/modifying environment variables. The rest of this subtopic shows you how to do that in Windows.

  • Using the Environment Variable GUI
    • Click to the Windows symbol on the bottom-left where "Start" used to be
    • Right-Click on "Computer", choose "Properties" and click the link for "Advanced System Settings"
    • In the *top* window, Click "New" add a variable or click "Edit" to modify an existing one.
    • The variable should be a ';' seperated list of directories.
  • At the DOS prompt
    • To see the current value of variable VAR:
         > echo %VAR%
    • To modify variable VAR:
         > set VAR=%VAR%;dir1;dir2 ...
    • To create variable VAR:
         > set VAR=dir1;dir2....

Install Haskell Platform and MingW[edit]

  • Install the Haskell Platform for Windows.
  • Optional : Install MinGW as per the instructions on their web site. Also install MSYS and mingw-make. A version of MinGW does come with Haskell Platform but excludes MSYS and 'make'.

Install libxml[edit]

  • Download and unzip the latest libxml2 and libxml2-dev archives from Gnome.
  • To the PKG_CONFIG_PATH environment variable add the 'pkgconfig' directory in libxml2-dev\lib.
  • To the INCLUDE environment variable add the path to the 'include' directory from libxml2-dev.

Install the GTK/Glade bundle[edit]

  • Download and install the bundled GTK and Glade binary.
  • To the PKG_CONFIG_PATH environment variable add the 'pkgconfig' directory. The default path should be "C:\Program Files\Gtk+\lib\pkgconfig".
  • To the INCLUDE environment variable add the 'libglade-2.0' directory. The default path should be "C:\Program Files\Gtk+\include\libglade-2.0".

Install the Haskell bindings[edit]

  • At the DOS prompt run 'cabal install gtk2hs-buildtools'.
  • At the DOS prompt run 'cabal install gtk'. Make sure you have at least 1.5 GB RAM otherwise this compilation will die.
  • At the DOS prompt run 'cabal install glade'.

Self check[edit]

Test the GTK install[edit]

  • In some appropriate temporary directory run 'cabal unpack gtk'. This downloads and unpacks the Haskell sources.
    • Run the demos (using mingw-make)
      • If you installed MinGW then in the 'demo' directory, navigate into the 'hello' directory and run mingw32-make.exe. Now run the executable that was created.
    • Run the demos (manual compilation)
      • In the 'demo' directory, navigate into the 'hello' directory and run 'ghc --make World.hs -o helloworld.exe'. Now run the executable that was created.

Test the Glade install[edit]

  • In some appropriate temporary directory run 'cabal unpack glade'. This downloads and unpacks the Haskell sources.
    • Run the demos (using mingw-make)
      • If you installed MinGW then in the 'demo' directory, navigate into the 'gladetest' directory and run mingw32-make.exe. Now run the executable that was created.
    • Run the demos (manual compilation)
      • In the 'demo' directory, navigate into the 'gladetest' directory and run 'ghc --make GladeTest.hs -o gladetest.exe'. Now run the executable that was created.

Common Errors[edit]

  • Glade.h is not found
 gtk2hsC2hs.exe : glade/glade.h: File does not exist

Probably instead of installing the GTK/Glade bundle you installed them seperately. The GTK/Glade bundle comes with the "include/libglade-2.0" containing a number of header files. For some reason this directory is not included in stand-alone GTK and Glade installers. Install the bundle and add this directory to the INCLUDE environment variable.

  • Cabal cannot find gtk2hsC2hs.
 Please install gtk2hs-buildtools' first and check 
 that the installdirectory is in your PATH (e.g. HOME/.cabal/bin). 
 cabal: Error: some packages failed to install

Somehow the path to the cabal bin directory has been lost. To the PATH environment variable re-add the cabal bin directory. The default path should be "%USERPROFILE%\AppData\Roaming\cabal\bin".

  • Spinner error with the 'notebook' demo

Running the 'notebook' demo in the GTK install gives:

   [1 of 1] Compiling Main             ( Notebook.hs, Notebook.o )
   Notebook.hs:14:35:
   Not in scope: type constructor or class `Spinner'
   Notebook.hs:78:13: Not in scope: `spinnerNew'
   Notebook.hs:101:2: Not in scope: `spinnerStart'
   Notebook.hs:109:2: Not in scope: `spinnerStop'
   mingw32-make: *** [notebook] Error 1

This happens because this demo uses the new Spinner widget in GTK 2.22. Since this is not available in GTK 2.16 you get this error.