Personal tools

Gtk2Hs/Windows

From HaskellWiki

< Gtk2Hs(Difference between revisions)
Jump to: navigation, search
(copy from Gtk2hs main page)
 
(Common Errors: promote section)
Line 46: Line 46:
 
*** 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.
 
*** 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 ====
+
== Common Errors ==
 
* Glade.h is not found
 
* Glade.h is not found
 
gtk2hsC2hs.exe : glade/glade.h: File does not exist
 
gtk2hsC2hs.exe : glade/glade.h: File does not exist

Revision as of 13:51, 29 August 2011

Contents

1 Windows 7 32 bit

1.1 Changing Environment Variables

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

1.1.1 Install Haskell Platform and MingW

  • 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'.

1.1.2 Install libxml

  • 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.
  • To the INCLUDE environment variable add the path to the 'include' directory from libxml2-dev.

1.1.3 Install the GTK/Glade bundle

  • 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".

1.1.4 Install the Haskell bindings

  • 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'.

1.1.5 Test the GTK install

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

1.1.6 Test the Glade install

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

2 Common Errors

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