Haskell Platform 2010.1.0.0 and wxHaskell on Windows

Edit: Please note that the issue described in this post has been fixed on newer versions of Haskell Platform, so you shouldn’t need to follow the instructions here.

Dan Haraj asked a question about installing wxHaskell on a Windows 7 machine. Since he was having problems, and since I have never verified wxHaskell installation on Windows 7, I agree to look into the problem.

Bottom line is that wxHaskell is fine on Windows 7, but there’s a problem with the Haskell Platform 2010.1.0.0 Windows installation. The issue is that the GHC version used doesn’t include C++ support, and wxHaskell needs this to build.

You have a couple of options for installing wxHaskell on Windows:

  1. Just use an older Haskell Platform installer – these work fine.
  2. Copy the required C++ support into Haskell Platform 2010.1.0.0 yourself from a MinGW installation. This is a horrible hack, as the files you will be copying to not correspond exactly to the MinGW version shipped in the Haskell Platform. They are close enough to work, however, if doing this doesn’t mortally wound your sense of software aesthetics.

You will need a copy of MinGW with gcc 3.4.5 installed, including C++ support. The automated installer at Sourceforge will install the same versions I used – just remember to tick the box marked ‘C++’ in the installer.

Once you have a suitable MinGW installation, do the following:

  • Copy cc1plus.exe from a MinGW 3.4.5 install into c:\Program Files (x86)\Haskell Platform\2010.1.0.0\mingw\libexec\gcc\mingw32\3.4.5
  • Copy libstdc++.a from a MinGW 3.4.5 install into c:\Program Files (x86)\Haskell Platform\2010.1.0.0\mingw\lib
  • Copy include\c++ directory from a MinGW 3.4.5 install into c:\Program Files (x86)\Haskell Platform\2010.1.0.0\mingw\include\c++

If you are using Windows 7, you will need to have Administrator privilege to do this.

After this, you can install wxHaskell on Windows 7 as follows:

  1. Open a cmd.exe window running as Administrator (press Start, type cmd into the search box and right click on the cmd icon to use the ‘Run as Administrator’ option.
  2. Type cabal install wx

You should have a working wxHaskell installation in a few minutes.

A couple of notes:

  • cabal install wx –user doesn’t work on Windows 7 without Administrator privilege, which kinda defeats the object. I will need to look into the reason for this, but it’s not at the top of my list.
  • You can’t run cabal install wx in an MSys shell. It breaks horribly. This means you build wxWidgets in a different shell to the one in which you install wxHaskell.

I’ve updated the wiki to reflect this…


4 thoughts on “Haskell Platform 2010.1.0.0 and wxHaskell on Windows”

    1. Out of interest, did you do this with the 2010.1.0.0 Haskell Platform or the older version? I agree about the potential problems of mixing MinGW platforms, but (with my wxHaskell maintainer hat on) I need to be able to get people going on the latest versions of tools, or they think the platform is going unmaintained.

      Your approach is a little cleaner than mine, if it works for the latest Haskell Platform.

  1. hi, thanks for this. i finally managed to get wxHaskell installed on Win XP. but i’m having trouble while compiling and linking programs using ghc.

    i get –
    ghc –make main.hs -package wx
    Linking main.exe …
    C:\msys\1.0\mingw\lib/libmingw32.a(tlssup.o):tlssup.c:(.text+0xa8): undefined reference to `LoadLibraryA@4′
    C:\msys\1.0\mingw\lib/libmingw32.a(tlssup.o):tlssup.c:(.text+0xc8): undefined reference to `GetProcAddress@8′
    C:\msys\1.0\mingw\lib/libmingw32.a(tlssup.o):tlssup.c:(.text+0xe5): undefined reference to `GetProcAddress@8′
    C:\msys\1.0\mingw\lib/libmingw32.a(tlssup.o):tlssup.c:(.text+0x15f): undefined reference to `FreeLibrary@4′
    collect2: ld returned 1 exit status

    it seems to be a problem with multiple mingw installs. i have compiled wxHaskell using –extra-include-dirs and lib-dirs and pointed them to the mingw within Haskell. when it compiles (shown in -v3 verbose mode) it uses the Haskell platform binaries. yet at the linking stage it seems to be looking for the mingw on my local machine. any ideas on how to fix this ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s