(Unfortunately, there are still build problems on Sun Solaris – we are looking for build volunteers :-)

3 Prerequisites

Ensure you have a recent GHC compiler – version 6.10.3 or higher is recommended. In principle, any Haskell 98 compiler that supports the standard FFI libraries along with cabal install should work. We have discontinued support for building without cabal.

Windows: You will need wx-config for Windows, MinGW 5.1.6 and MSYS 0.1.11 (these are the latest versions at the time of writing). You must select the C++ compiler option when installing MinGW.

Mac OS X: you need to install the gcc compiler, which is part of the Apple Developer Tools. These tools are shipped with Panther and are installed by invoking Applications/Installers/Developer Tools/Developer.mdmg.

You should install the current stable version (2.8.10) of wxWidgets for your platform - versions older than 2.8.1 are no longer supported. Build instructions are given for Windows - on most other platforms you should be able to obtain wxWidgets using your package manager (you may need -developer packages).

We assume in this guide that the variable $wxwin points to your wxWidgets installation directory, for example: ~/dev/wxGTK-2.8.10.

This will take quite some time and generate lots of text in the MSYS shell. Assuming it is successful, a DLL is generated in /c/path/to/wxWidgets/gcc_dll, which you will need to copy to a location where it can be found when running your executables.

5.2 On Unix systems

You should follow the instructions on the wxWidgets website if there are no suitable packages for your environment. You probably want to use GCC to build wxWidgets, as this makes it more likely that cabal will understand the output of wx-config.

On most Unix platforms, wxWidgets build goes something like: create a mybuild directory in the wxWidgets directory, and run configure and make from that directory (and take the time to get some coffee :-).

5.3 Testing wxWidgets build

Now try out a few samples of wxWidgets to see if it all works correctly:

> cd ../../samples/controls
> make
> ./controls

Note that you build from the local samples directory that resides in the mybuild directory.

And also try if wx-config works too:

> wx-config -v

ChengWei: I've found that if you put wx-config in some system directories, such as c:\windows\system32, 'cabal install wx' will complain "wx-config: does not exist". To put it in another directory in %PATH% will solve this problem. Tested on Windows 7, Haskell platform 2010 2.0.0.0.

6 Building wxHaskell

Since wxHaskell 0.12.1.1, we only support building using Cabal.

For all platforms installation is straightforward, provided that:

wx-config is somewhere in the path

The WXWIN environment variable points to the root of your wxWidgets installation

WINDOWS PLATFORMS ONLY: You may also need to set WXCFG=gcc_dll\mswu

You can then install wxhaskell as follows (in a Windows cmd.exe shell, not an MSys shell):

> cabal update
> cabal install wx

Note that on Windows 7 machines, your command window must be running as Administrator.

Note that on Unix systems, you may prefer something like

> sudo cabal install --global wx

Windows developers who don't update environment variables can do something like this in an MS-DOS shell:

6.1 Out of memory errors

There have been reports of out of memory errors when compiling wxcore on some machines, notably 64 bit Linux hosts. Wxcore contains some very large auto-generated source files, and increasing the memory available to the GHC runtime can help.

Try something like:

> export GHCRTS='-M512m'

to allocate 512 MB to the GHC RTS. This has been reported to be sufficient.

7 Source Release

You can obtain a source release of wxHaskell from the darcs repository. Darcs creates a wxHaskell directory for you; we assume in the following example that your $wxHaskell directory will be ~/dev/wxhaskell.

8 Test wxHaskell

macosx: wxHaskell programs need to be turned into application bundles before they can be run. Look at the Mac OS X notes for more information.
You can also run the examples from GHCi – a great development environment!

> ghci -package wx BouncingBalls.hs
> main

Notes:

wxHaskell programs are not always properly reïnitialized when started the second time from a GHCi prompt. This is due static variables in the wxWidgets C++ code, and we are working with wxWidgets developers to remove those bugs. Currently, GHCi only works well with wxWidgets 2.4.2.
gtk: Unfortunately, one can only start a wxWidgets program once with GHCi on GTK (rendering it useless).
macosx. You need to use a special command to run wxHaskell applications, see the Mac OS X notes from more information.
Have fun!