Gtk2Hs: A GUI Library for Haskell based on Gtk+ http://haskell.org/gtk2hs/ The library currently wraps most functions from the Gtk+ 2.8 libraries. Furthermore there is support for cairo, cairo svg loader, pango, the libglade UI loader, the Gtk+ OpenGL extension, the SourceView widget, the GConf configuration system, and the Mozilla rendering engine embedded in a widget. The GHC Haskell compiler, version 6.0 or greater, is required. Gtk2Hs is known to compile on Linux, Windows, OSX, FreeBSD, and Solaris. These instruuctions are about building Gtk2Hs from source. If you would rather install a binary (pre-compiled) package, please check the Gtk2Hs web site. Building -------- This section assumes that you are building a source distribution (.tar.gz). If you are building on Windows, read "Building on Windows" first. If you are using the darcs version, please read "Building from darcs". The following assumes that the sources are in ~/gtk2hs. 1. Run the configure script. ---------------------------- The configure script has several useful options, particularly: --with-hc= Uses the specified GHC for compilation and for installation of the package. --with-hcflags= If you find that you need to pass any special flags to the Haskell compiler then use this option to specify them. This overrides the default flags which is just "-O" to compile using optimisations. Use -O0 for a quicker build. --enable-profiling Build profiling versions of all the libraries in addition to the normal ones. --disable-split-objs By default the libraries are built using GHC's 'split-objs' feature. This makes for considerably smaller binaries since it allows the linker to include only the functions needed. However split-objs doesn't work on every platform so if you get linker errors then you can can try disabling it. Building the Gtk2Hs libs with split-objs turned on is considerably slower and uses more memory so you may prefer to turn it off. --with-user-pkgconf Instead of registering Gtk2Hs with GHC's global package file, register in the user's one instead. This is useful if you want to install to your own user space rather than system wide. --enable-docs This builds reference documentation in html format. These are also available from the website but you may prefer to keep a local copy. You will need haddock version 0.7 or later to build the documentation. --enable-PACKAGE {- substitute package name for PACKAGE -} --disable-PACKAGE Gtk2Hs contains bindings to some libraries that are not part of Gtk+ but closely related. This option forces a particular package to be built or not built. The default is to autodetect if a given package is installed (except in --packager-mode where the default is --disable-PACKAGE for all packages). At the time of writing the possible values for PACKAGE are: libglade : A library to load XML user interface descriptions that were generated by the Glade user interface builder. gconf : A library to store configuration data in a Gnome-compatible way. sourceview : An enhancement of the TextView-widget of Gtk+. It adds features useful for editing source code, e.g. syntax highlighting. firefox / seamonkey / xulrunner / mozilla : A widget that renders HTML. cairo : A library for rendering vector graphics. svg : SVG file rendering for cairo. opengl : Bindings for the Gtk OpenGL extension --disable-deprecated There are many Gtk+ APIs that have been deprecated as new versions of Gtk+ have come out. This option makes sure that no deprecated APIs are used. You might want to use this option to make sure that you are not using deprecated APIs in your new programs. --with-pkgconf= Instead of registering Gtk2Hs with GHC's global package file, use a specific file. If this file doesn't exit, it is created. --without-pkgreg This option disables registering the packages with GHC at all. This is useful to people building on one machine but wanting to install on another, e.g. people packaging Gtk2Hs for use with a package management system. --enable-packager-mode Enables --without-pkgreg and does not build any optional packages unless these are specified with --enable-PACKAGE. On Windows it also does some other stuff that helps with building an installer. If you want to do a quick build use: ~/gtk2hs:$ ./configure --with-hcflags=-O0 --disable-split-objs If you want to install into your home directory rather than system-wide use: ~/gtk2hs:$ ./configure --prefix=$HOME --with-user-pkgconf 2. Building the sources. In the following "make" stands for GNU make. If your system has a program called "gmake" then "make" is probably not GNU make. In this case use "gmake". To build the sources you issue: ~/gtk2hs:$ make 3. Install the libraries. ------------------------- If you are installing system-wide then use: ~/gtk2hs:$ sudo make install or if you use the 'su' command rather than 'sudo': ~/gtk2hs:$ su ~/gtk2hs:# make install If you configured to install into your home directory then just say: ~/gtk2hs:$ make install 4. Compiling a program. ----------------------- To get started, you can compile and run one of the programs that reside in the demo/ directory in the gtk2hs source directory. For example: ~/gtk2hs/demo/hello:$ make which has the same effect as typing ~/gtk2hs/demo/hello:$ ghc --make World.hs -o helloworld The program should pop up a dialog box when you say ~/gtk2hs/demo/hello:$ ./helloworld 5. Documentation ---------------- The documentation is avaliable on the website. You can also build the documentation locally. You say ~/gtk2hs:$ ./configure --enable-docs 6. Deinstallation ----------------- So long as you do not delete the source tree you can easily uninstall everything that gtk2hs installed by saying ~/gtk2hs:$ make uninstall in the root of the source tree. This will properly remove the package from GHC and remove any installed file. Alteratively, if you do not keep the source tree around then you can uninstall by unregistering the packages with ghc-pkg and deleting all the installed files. Assuming that you installed in the default location (ie did not specify --prefix= during ./configure) then that would mean doing the following: # for pkg in glib gtk cairo glade gtkglext svgcairo gconf sourceview mozembed soegtk; \ > do ghc-pkg unregister $pkg; done # rm -rf /usr/local/lib/gtk2hs/ # rm -rf /usr/local/share/doc/gtk2hs/ #if you installed the docs Building on Windows -------------------- Install MSYS and MinGW. Download a build of Gtk+, you will need the "dev" version which includes all the header files and libraries. Make sure that GHC and that pkg-config.exe can find all your Gtk+ libraries. The configure script should complain if this is not the case. Building from darcs ------------------- 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. Building the development version proceeds as normal building, except that you need to run "autoreconf" first. You will need sufficiently new versions of the automake/autoconf toolsuite installed. (automake 1.8.x, autoconf 2.59) Note that dependencies are generated only in a clean tree. Hence, if the import structure of files change, the build might fail due to missing dependencies. The easy way out is "make clean; make", the faster way is to delete the lib*.deps files in each subdirectory. Please report problems to the Gtk2hs mailing list . The Gtk2Hs team.