Building from sources

In principle we recommend the use of binary releases, but wxHaskell also has a build system to compile directly from sources. The build process has been specialized for three main platforms:

wxHaskell has been build successfully on (at least) the following configurations:

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

Prerequisites

Ensure you have a recent GHC compiler – version 6.8.1 is recommended (but any version >= 5.04.3 will work). In principle, any Haskell98 compiler that supports the standard FFI libraries will also work.

Next, you should install the previous stable version (2.6.4) of wxWidgets for your platform. (wxHaskell doesn't support latest stable version (currently 2.8.4) now.) We assume in this guide that the variable $wxwin points to your wxWidgets installation directory, for example: ~/dev/wxGTK-2.6.4.

If you have a source release of wxHaskell, just unpack it in a suitable directory. In the following descriptions, we assume that the variable $wxhaskell points to your installation directory, for example: ~/dev/wxhaskell.

(Note: GHC 6.6.x or higher can't build old source releases. So you must get source from darcs by below command.)

If you do not have a source release of wxHaskell, you need to check it out 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.

> cd ~/dev
> darcs get --partial --set-scripts-executable http://darcs.haskell.org/wxhaskell/

Building wxWidgets

windows-msc: this section describes how to build wxWidgets using standard gnu tools -- there is a separate section on building the library with Microsoft Visual C++ on windows.

According to the wxWidgets preferred installation, create a mybuild directory in the wxWidgets directory, and run configure and make from that directory (and take the time to get some coffee :-).

> cd $wxwin
> mkdir mybuild
> cd mybuild
> ../configure --enable-unicode
> make
> make install
> cd contrib/src
> make
> make install
Notes:

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

Building wxHaskell

First, we configure the library for your platform.

> cd $wxhaskell
> ./configure --enable-split-objs --hcprof
Notes:

After configuration, we build and install the libraries (and take some more time to drink more coffee :-).

> make
> make install
> make wx
> make wx-install
Notes:

Test wxHaskell

If everything succeeded, you should be able to run a test program.

> cd samples/wx
> ghc -package wx -o helloworld HelloWorld.hs
> ./helloworld

Notes:

You can also run the examples from GHCi – a great development environment!

> ghci -package wx BouncingBalls.hs
> main

Notes:

Have fun!
   -- Daan Leijen.

toplast update: "5 March 2008".