If, like me, you wish to perform graphical operations with Haskell you need a library like SDL. Unfortunately most of the Haskell world resides in Linux so it is pretty hard to find good guides for Windows. This guide describes my endeavor to get things working.
I’ll assume that you have nothing installed yet, so you might be able to skip some of these steps.
1. Install the Haskell Platform
You can get it from http://www.haskell.org/platform/ and it will include most of what you will need to work with Haskell on Windows (or any other platform). Installation is as easy as double clicking the installer.
2. Install the MinGW-MSYS tool chain
In order for Cabal (a distribution-manager like apt-get but then just for Haskell) to be able to build packages that have no native Windows libraries we need a Linux like tool chain for Windows.
- Download the MinGW installer from http://www.mingw.org/wiki/Getting_Started (in the middle of the page there is a blue link to mingw-get-setup.exe)
- Run the installer, for legacy reasons install it in a path that does not contain spaces. I'll asume for now that you've installed it in C:\MinGW
- During the end of the installation a package manager will show. Install the meta package MSYS and click apply changes in the menu.
- Add C:\MinGW\bin\, C:\MinGW\, and C:\MinGW\msys\1.0\bin\ to the PATH environment variable
3. Install the SDL development libraries
Now we need to install the SDL development libraries and add them to the PATH variable so that the Haskell implementation can link and build.
- Download the SDL-devel-1.2.15-mingw32.tar.gz archive from http://www.libsdl.org/download-1.2.php and extract. I'll assume it is located in C:\SDL
- Add C:\SDL\, and C:\SDL\bin to the PATH environment variable
4. Build Haskell's SDL implementation
Ok final steps!
- Open a command prompt
- Run cabal install SDL --extra-include-dirs=C:\SDL\include --extra-lib-dirs=C:\SDL\lib
- This operation should complete with the message 'Installed SDL-0.6.5'
5. In Conclusion
Building things with Cabal is quite a hassle especially since it uses both the PATH variable and explicitly given paths to find all dependencies, error messages are not to clear either. I hope this guide helps you and saves you some time as it took me two days to get this exactly right. If you wish to see if all really works why not try building and running this little program, it is the reason why I went trough all the steps to get SDL working. (Just left-click and drag to create a rectange, middle click to change the color, and right click to finish the rectangle).
Note: I am aware that the Haskell Platform includes its own version of MinGW but it does not include the MSYS library which is vital under Windows. It is also not easy to modify the built in version of MinGW and according to the docs the build in version can live happily together with the stand alone version.