Gtk2Hs: A GUI Library for Haskell based on Gtk+ Contents: * Overview * Building * Building form darcs * Running the demos * Documentation * Deinstallation * Building on Windows Overview -------- http://haskell.org/gtk2hs/ Gtk2hs is a set of Haskell packages wrapping the GTK+ GUI stack: * tools (Tools to build gtk2hs) * glib (GLib2 library) * gio (VFS library) * cairo (Vector graphics library) * pango (Unicode text rendering) * gtk (GTK+ GUI toolkit) The following are also available, but are not built by default when installing the 'gtk' package. In particular, these might not have a binary library on Windows available: * gconf (GConf2 configuration system) * glade (libglade UI loader) * gstreamer (Media codec library) * gtkglext (Gtk+ OpenGL extension) * gtksourceview2 (Source code editor) * svgcairo (Cairo SVG loader) * vte (Terminal emulator) * webkit (WebKit rendering engine) * soegtk (Graphics library for book "The Haskell School of Expression") The following packages are deprecated: * gnomevfs (replaced by gio) * mozembed (replaced by webkit) * sourceview (replaced by gtksourceview2) The GHC Haskell compiler, version 6.10.x or greater, is required. Gtk2Hs is known to compile on Linux, Windows, OSX, FreeBSD, and Solaris. ghc-6.12.2 has a runtime issue that can cause gtk2hs apps to crash (http://hackage.haskell.org/trac/ghc/ticket/4038), so better avoid it. These instructions are about building Gtk2Hs from source. Certain Linux distributions might provide binary packages via their packaging system. Building -------- From version 0.11, gtk2hs is now distributed as separate packages on hackage. So the easiest way to install it is using "cabal-install", eg.: cabal install gtk Building the Gtk2Hs packages requires the installation of Gtk2Hs-specific build tools. You can install these by issuing: cabal install gtk2hs-buildtools Note that you need to have ~/.cabal/bin on your PATH since otherwise building the libraries will fail, saying that e.g. gtk2hsC2hs cannot be found. Building on Windows -------------------- Installation on Windows is nearly as easy as on Unix platforms. However, you need to download the pre-compiled binary libraries of Gtk+ and all it's dependent libraries. Point your browser to http://www.gtk.org/download-windows.html and download one of the "All-in-one bundles". Note that you do *not* need to install MinGW nor MSys (but it does not hurt if they are installed on your system). Install the binaries by unpacking them into a directory without spaces. Again, this is very important: *** Do not install the binaries into a directory with embedded spaces. *** Ensure that the /bin directory is added to your %PATH%. You can ensure that everything is installed correctly if you can say pkg-config --cflags gtk+-2.0 and you see some compiler flags that contain the path into which you have installed the binary bundle. We had reports that the binaries containing version 2.22 do not work and that the version 2.16 gives the following errors when running cabal: setup.exe: gtk-0.12.0: library-dirs: c:/.../dist/win64/libpng-1.4.3-1/lib doesn't exist or isn't a directory This problem can be worked around by creating said directory and copying libpng into it. Any further feedback regarding the installation of the binary packages is welcome. You may now install the cabal packages of Gtk2Hs into any directory you like (including one that contains embedded spaces). Note that cabal installs the tools necessary to build into something like C:\Documents and Settings\%user%\Application Data\cabal\bin Make sure that this path is also in your %PATH% variable! ghci and Gtk2Hs on Windows Due to the way cabal registers packages with ghc, it is quite difficult to perform the renaming of libraries which is necessary for the binary Windows bundle to work. As a consequence, the cabal package can do this renaming only with Cabal 1.8 (shipped with ghc 6.12). If you use ghc 6.10 or earlier, you need to upgrade your Cabal system to 1.8 if you want to build Gtk2Hs with ghci support. Note that it is always possible to build executables on Windows. Building on Mac OS X -------------------- There is nothing particular about Mac OS X, except that pango 1.26 has a bug that makes application seem to hang. Furthermore, there are libraries that use the native Aqua API as a backend to Gdk. It seems that this porting effort has stalled and as of now does not support certain features as copy and paste. Use at your own risk. NOTE: If you use Quartz backend on Mac OS X, please building with the flag -have-quartz-gtk to disable function gdk_x11_drawable_get_xid, otherwise you will get linking error : Loading package gtk-0.12.0 ... linking ... : unknown symbol `_gdk_x11_drawable_get_xid' ghc: unable to load package `gtk-0.12.0' Building from darcs ------------------- This section assumes that you are building from a darcs checkout or snapshot. If you are building on Windows, read "Building on Windows" first. The following assumes that the sources are in ~/gtk2hs. Building the latest sources from the darcs repository is normally straight forward. In fact, since Gtk2Hs is only a wrapper around Gtk+, the development version is usually not as "unstable" as it is for most software projects. You must have all the appropriate development packages installed of course (glib-2.0, gio-2.0, pango, cairo, gtk+-2.0) for all the packages you wish to build. You can check the existence by running 'pkg-config --list-all'. You can get the latest development darcs source tree by running: ~:$ darcs get --lazy http://code.haskell.org/gtk2hs The easiest way to build everything is to run the script: ~/gtk2hs:$ sh bootstrap.sh which build the tools and all the main supported libraries. Otherwise you can run "cabal install" by hand in a appropriate order in a desired subset of the individual package directories. Running the demos. ------------------ To get started, you can compile and run one of the programs that reside in the demo/ directory in the respective packages. For example: ~/gtk2hs/gtk/demo/hello:$ make which has the same effect as typing ~/gtk2hs/gtk/demo/hello:$ ghc --make World.hs -o helloworld The program should pop up a dialog box when you run ~/gtk2hs/gtk/demo/hello:$ ./helloworld Documentation ------------- The documentation is available on the website and in hackage. You can also build the documentation locally with cabal. Deinstallation ----------------- Although cabal doesn't allow to uninstall files at the moment, you can unregister the packages with ghc-pkg and delete the installed files manually. Eg reversing the order in bootstrap.sh: for pkg in webkit vte svgcairo soegtk gtksourceview2 gtkglext gstreamer glade gconf gtk pango cairo gio glib ; \ do ghc-pkg unregister $pkg; done Unregistering packages is usually enough to be able to work with different versions of Gtk2Hs. Please report problems to the Gtk2hs mailing list . The Gtk2Hs team.