Personal tools


From HaskellWiki

< WxHaskell
Revision as of 18:22, 29 June 2008 by Shelarcy (Talk | contribs)

Jump to: navigation, search


1 Overview

This page describes how to get a working wxHaskell installation on various platforms. The latest release (version 0.10.3) was on 2008-03-23.

The installation process has become increasingly stable and simple, but some of the information on this page could become outdated. Current development on wxHaskell takes place in the darcs repository at .

2 Getting wxWidgets

wxHaskell 0.10.x does not yet support wxWidgets 2.8 (although the current darcs version does). Generally, the recommended version to use is 2.6.4 [2.6.3 on Debian/Ubuntu Linux] as it's what the binaries are compiled against.

  • Windows:
    • Binary - you can skip this phase. you should just install wxHaskell. Because wxHaskell's dll statically links wxWidgets library.
  • MacOS X
    • Tiger - do not use the wxMac 2.5 that comes pre-installed, unless you really want to compile from source and to report back on how everything works out.
    • Leopard - the darcs version of wxhaskell now (2008-04-25) supports wxWidgets 2.8. We don't know if the one that ships with Leopard works yet. Want to give it a try? Otherwise, we do know that it runs with a self compiled wxMac.
  • Linux - the wxWidgets that ships with your system (as long as it's the 2.6 one and not the 2.8 one) should work.

See the wxWidgets site for more details.

In addition, the following pages contain useful information on installing wxWidgets 2.6.4 (or, in some cases, wxWidgets 2.6.3) on various operating systems:

3 Getting wxHaskell

Obtain wxHaskell sources from Sourceforge.

OSX caveats:

  • The installation of wxWidgets provided with OSX Tiger will not work, as it does not have the wxThread symbols that wxHaskell does want to link against.
  • Programs compiled with wxHaskell do not work by default: you need to run macosx-app on them to let Mac OS X understand that the binary needs Carbon to do its UI.

4 Building and installing

4.1 Windows

4.1.1 GHC 6.8.3, wxWidgets 2.6.4, wxHaskell 0.10.3 (binary)

  1. Download the 0.10.3 release candidate from sourceforge
  2. Unpack wxhaskell-*.zip. And double-click wxhaskell-*\bin\wxhaskell-register.bat.
  3. wxhaskell-register.bat install wxHaskell to your system.

4.1.2 Assumptions (a.k.a. what I have tested)

  • GHC 6.4.2 (Jason Dagit reports success with GHC 6.5 as well).
  • Cygwin installation. See | wxHaskell cygwin page for detail, but broadly, you need Cygwin bash and install binaries.
  • wxWidgets built/installed in a path with no spaces in it. Actually you can use a path with spaces but there are a few rules. For example, I had ghc installed to this location:
    C:\Program Files\Visual Haskell
    So this required me to use the following configure command:
    ./configure --libdir=C:/Progra~1/Visual~1

The two important things here are: 1) You must use the forward slash and 2) you cannot use spaces.

Next I found that I needed to add C:\Program Files\Visual Haskell to my path so that the wxHaskell dlls could be located by windows.

  • Environment variables:
    • PATH should include MinGW and Cygwin binary directories. MinGW must come before Cygwin in PATH.
    • WXHASKELL environment var points to wxHaskell install directory.
    • WXWIN environment directory points to wxWidgets install directory.

For more detailed information, see Installing wxWidgets 2.6.4 on Microsoft Windows 9x/ME, Windows NT, Windows 2000, Windows XP, and Windows CE.

4.2 Mac OSX

4.2.1 Mac (Intel and PowerPC), Tiger (10.4.11), GHC 6.8.2, wxWidgets 2.6.4, wxHaskell 0.10.3 (binary)

  1. Download and install wxWidgets for mac (wxMac 2.6.4) from (make sure you configure with --enable-unicode)
  2. Download the wxhaskell binary from sourceforge
  3. Open the dmg, double-click the .pkg file

For more detailed information, see Installing wxWidgets 2.6.4 on Mac OS X or Installing wxWidgets on wxCocoa.

4.2.2 MacIntel, Tiger (10.4.11, XCode 2.5), GHC 6.8.2, wxWidgets 2.6.4, wxHaskell 0.10.2 (hackage)

built on 2008-02-16

  1. Download and install wxWidgets for mac (wxMac 2.6.4) from
    • I changed into the wxMac topdirectory and used: ./configure --disable-monolithic --enable-display --enable-unicode --with-opengl --with-mac --without-odbc --enable-mediactrl && make && sudo make install
    • sudo mkdir -p /usr/local/wxhaskell/bin
    • sudo ln -s /usr/local/bin/wx-config /usr/local/wxhaskell/bin
  2. sudo cabal install wx-core
  3. cabal install wx
  • Enjoy. The TimeFlows and BoucingBalls examples still suffer from not having a correct default background color. This should not affect you too much: just explicitly set the background color.
    • Note that you need to run macosx-app on the programs you have built before you can manipulate the windows that program puts up. This installation process puts it in /usr/local/wxhaskell/bin/macosx-app
  • Does wxWidgets 2.8.0 work at all? [yes! in the darcs version of wxhaskell as of 2008-04-25]

Again, for more detailed information, see Installing wxWidgets 2.6.4 on Mac OS X or Installing wxWidgets on wxCocoa.

4.3 Linux

4.3.1 Sources

Built wxGTK-2.6.4 from sources with the configuration:

/usr/local/src/wxGTK-2.6.4/mybuild$ ../configure --enable-sound --enable-unicode

Add /usr/local/lib to your /etc/ before running sudo ldconfig after installing wxGTK.

Build wxHaskell from the darcs repository, configured with ./configure --enable-split-objs -hcprof, and follow the usual installation documentation from here on. The --enable-split-objs and -hcprof options are not mandatory, but they are nice to have

Note 2008-02-20: there was a bug that made --with-opengl necessary on some systems (depending on how wxWidgets was built), but it has been fixed

For more detailed information, see Installing wxWidgets 2.6.3 on Motif, Installing wxWidgets 2.6 on GTK+, or Installing wxWidgets 2.6.4 on X11.

4.3.2 Debian and Ubuntu Ghc 6.6 version

For Debian Linux systems:

  1. get wxWidgets 2.6
    • aptitude install libwxgtk2.6-dev
  2. obtain the wxhaskell-bin-debian-gtk2.6.3-ghc6.6-0.10.3.deb package from sourceforge
    • Install it with dpkg -i

You may need to add /usr/local/lib to your library search path. You can do that by making a file called /etc/ containing:


after adding the file, run ldconfig. Ghc 6.8 version
  1. get wxWidgets 2.6
    • aptitude install libwxgtk2.6-dev
  2. get ghc
    • apt-get --target-release=unstable install ghc6
  3. obtain the wxhaskell-bin-gtk2.6.3-ghc6.8.2-0.10.3.deb package from sourceforge
    • Install it with dpkg -i

4.3.3 Gentoo

wxHaskell is available in portage for x86, amd64, sparc and ppc

ACCEPT_KEYWORDS="~x86" emerge wxhaskell

(users of other arches should use their arch keywrods as appropriate)

4.3.4 Fedora Core 6

There is no wxHaskell package to go with the ghc-6.6 packages. You will have to compile it yourself. This a simple matter of:

  • Installing wxGTK:
    • yum install wxGTK-devel
  • Getting the sources:
  • Configuring, building and installing:
    • configure && make && make install && make wx && make wx-install

5 Troubleshooting

5.1 Compilation issues

  • Trouble building wxWidgets (MacOS X Tiger)
    • ld: /System/Library/Frameworks/WebKit.framework/WebKit load command 20 unknown cmd field
    • /usr/bin/libtool: internal link edit command failed
    • make: *** [lib/libwx_macu_core-]
    • Likely Solution: Upgrade to XCode >= 2.5
  • Can't build wxWidgets 2.6 (MacOS X Leopard)
    • Solution: upgrade to wxWidgets 2.8 and the darcs version of wxhaskell (2008-04-25)
  • Configure Succeeded (and nothing more)
    • Solution: Upgrade to the latest version of Cabal and cabal-install (darcs)
  • error build wxcore
    • /usr/libexec/gcc/i686-apple-darwin8/4.0.1/libtool: can't locate file for: -lwx_macu_media-2.6
    • /usr/libexec/gcc/i686-apple-darwin8/4.0.1/libtool: file: -lwx_macu_media-2.6 is not an object file (not allowed in a library)
    • Solution: try --enable-mediactrl in the wxWidgets configure
  • Too many levels of symbolic links (Linux)
    • UNKNOWN!

5.2 App-compilation issues

  • Could not find module `Graphics.UI.WX':
    • Solution Make sure you build and install the wx package too (wxhaskell comes in two parts, wxcore, which is what you get if you do ./configure; make; make install; and wx, which you can install by cd'ing into its directory and doing the standard Cabal stuff)
  • sample application dies with something like (Linux)
    • /usr/lib/ undefined reference to `wxGLCanvas::SwapBuffers()'
    • /usr/lib/ undefined reference to `wxGLCanvas::SetCurrent()'
    • /usr/lib/ undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)'
    • /usr/lib/ undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, wxGLCanvas const*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)'
    • /usr/lib/ undefined reference to `wxGLCanvas::SetColour(wchar_t const*)'
    • collect2: ld returned 1 exit status
    • Solution Update to the latest wxhaskell (the darcs version on 2008-02-20) (before, --with-opengl was required, now it is not)
  • Unknown...
    • /usr/lib/ undefined reference to `wxWindowBase::Hide()'
    • ...
    • `wxLog::AddTraceMask(wxString const&)' /usr/lib/ undefined reference to `wxHtmlHelpController::GetFrame()'
    • /usr/lib/ undefined reference to `wxPrintData::SetQuality(int)'
    • collect2: ld returned 1 exit status

5.3 Runtime issues

  • sample applications just sit there doing nothing (MacOS X)
    • Solution: macosx-app the application
  • sample applications segfault!
    • Solution: upgrade wxhaskell to the darcs version. It supports wxWidgets 2.8 as of 2008-04-25
  • wxhaskell builds fine, but sample applications do this:
    • dyld: Symbol not found: __ZN8wxThread11TestDestroyEv
    • Referenced from: /usr/local/wxhaskell/lib/libwxc-mac2.8.7-0.10.1.dylib
    • Expected in: flat namespace
    • trace trap ./BouncingBalls
    • Solution: try --enable-shared in wxWidgets config
  • Certain buttons and widgets (particularly, those inside of "boxed" environments) are not active (still a problem, 2008-02-20)
    • Solution: upgrade to latest version (0.10.3 as of 2008-03-23). It was a wxHaskell bug that is now fixed.
  • I only see the first letter of every word
    • Solution build wxWidgets with --enable-unicode. (We now use wchar* to store strings; but if wxWidgets is compiled without unicode, it thinks it's using char* and that null bytes are string terminators)
  • Loading package wxcore-0.10.3 ... : can't load .so/.DLL for: wxc-msw2.6.4-0.10.3 (addDLL: unknown error) (GHCi)
    • Unknown!: but you must check that compiled sample application works or not. If sample application doesn't work, please report error message to wxhaskell-users mailing-list (Don't forgot to report error number when reporting error message).
  • sample applications terminate with following error message (Windows). The applicattion failed to initialize properly (0xc0150002). Click OK to terminate the application.

5.4 Old issues

WARNING: potentially obsolete

  • Problems compiling wxHaskell (something like the below) (MacOS X)
    • /tmp/ghc29861.s:4379: Unknown pseudo-op:
    • .subsections_via_symbol
    • Solution: Make sure you have at least Xcode 1.5 (gcc 3.3 build 1671). Xcode 1.1 (gcc build 1495) is not enough
  • More linker trouble (MacOS X):
    • ld: out/wxc/master.o undefined symbol 36311 (__ZdaPv) can't be a weak definition
    • /usr/bin/libtool: internal link edit command failed
    • make: *** [out/wxc/libwxc-mac2.6.2-0.9.4.dylib] Error 1
    • Solution?: Add the gcc 3.3 version of libstdc++ to your dylib:
    • Solution?If you use gcc 4, try to add the following linker flags "-lSystemStubs -shared-libgcc -lstdc++-static". (libstdc++-static.a is part of XCode 2.3)
  • [OBSOLETE?] If you get linker errors like it not being able to find _TextziParserCombinatorsziParsecziChar_alphaNum_closure
    • Solution:Try editing config/ and setting HC=ghc -lHSparsec. This is likely not a mac-specific problem but related to the use of GHC 6.2 over 6.0.1. (not sure if this is still valid)
  • [OBSOLETE?] When compiling your Haskell program (MacOS X):
    • ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib
    • Solution:Adding -framework AppKit to the compiler switches for your Haskell program seems to help