For the very lazy
You need to have wxWidgets 2.8.10 installed on your machine (and compiled with MSys g++ if using Windows). Windows users should also get the Windows port of wx-config.
You have correctly configured all of te recommended wxWidgets environment variables, and have a recent version of GHC with an up to date cabal install.
This is all you need:
> cabal install wx
The build process has been tested against three main platforms:
- unix-gtk. General unix systems with GTK.
- macosx. Mac OS X.
- windows. General windows systems (i.e. win95 to winXP).
We support both building only with the gnu mingw32 C compiler (windows-mingw).
Please note that we have discontinued support for Microsoft compilers in the build system.
wxHaskell has been build successfully on (at least) the following configurations:
- windows. Windows 98, windows 2000, and windowsXP, using wxMSW 2.8.x.
- macosx. Mac OS X 10.4 (Tiger) and 10.5 (Leopard) with ghc 6.10.x and wxMAC 2.8.x.
- unix-gtk. Red Hat Linux 10 (Fedora), FreeBSD, and Gentoo Linux, using wxGTK 2.8.x.
(Unfortunately, there are still build problems on Sun Solaris – we are looking for build volunteers :-)
Ensure you have a recent GHC compiler – version 6.10.3 or higher is recommended. In principle, any Haskell98 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.
- macosx: 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 longr 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.
wxHaskell 0.12.x.x supports wxWidgets > 2.8.
- You will need to build using the MinGW compiler - instructions below.
- MacOS X
- Tiger - do not use the wxMac 2.5 that comes pre-installed.
- Leopard - wxHaskell now supports wxWidgets 2.8.
- Linux - the wxWidgets that ships with your system (as long as it's the 2.8 one and not the 2.6 one) should work.
- Backport of wxWidgets 2.8 for Debian and Ubuntu
- wxGTK - wxhaskell supports wxGTK.
- wxX11 - wxhaskell does not support wxX11 now. Use wxGTK instead.
See the wxWidgets site for more details.
Note: Microsoft compilers are no longer supported. The cabal build system cannot understand the output of wx-config for Microsoft compilers.
Using the MSys shell, and making sure that you have the C++ compiler oiption installed for MinGW (it is 'not' the default):
> cd /c/path/to/wxWidgets-2.8.10/build/msw > mingw32-make -f makefile.gcc BUILD=release MONOLITHIC=1 SHARED=1 UNICODE=1
That's it! 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.
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 :-).
> cd $wxwin > mkdir mybuild > cd mybuild > ../configure --enable-unicode > make > make install > cd ../contrib/src > make > make install
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 --version
Since wxHaskell 0.12.1.1, we only support building using Cabal.
For all platforms, provided that wx-config is somewhere in the path and that the WXWIN environment variable points to the root of your wxWidgets installation installation is very straightforward.
On Windows platforms, you may also need to set WXCFG=gcc_dll/mswu. You can then install wxhaskell as follows:
> cabal update > cabal install wx
Note that on Unix systems, you may prefer something like
> sudo cabal install --global wx
Lazy Windows developers who don't update environment variables can do something like:
> WXWIN=/c/path/to/wxWidgets-2.8.10 WXCFG=gcc_dll/mswu cabal install wx
The Windows installation is global by default.
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.
> cd ~/dev > darcs get --partial --set-scripts-executable http://code.haskell.org/wxhaskell/
You then build each of the key components in order:
> cd ~/dev/wxhaskell/wxdirect > cabal install > cd ../wxcore > cabal install > cd ../wx > cabal install
If everything succeeded, you should be able to run a test program.
> cd samples/wx > ghc -package wx -o helloworld HelloWorld.hs > ./helloworld
macosx: Unfortunately, wxHaskell programs do not work directly as generated by GHC. Look at the MacOS X notes for more information. You can also run the examples from GHCi – a great development environment!
> ghci -package wx BouncingBalls.hs > main
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.