SDL-0.5.0: WIN32
Building hsSDL on Win32
-----------------------
Bit Connor <bit@mutantlemon.com>
This is how I managed to get hsSDL working on Windows XP.
I used GHC version 6.6.1
1. Download the SDL mingw development package from the SDL website
http://www.libsdl.org
The file I used was SDL-devel-1.2.12-mingw32.tar.gz
2. Extract it somewhere. You will get a directory called SDL-1.2.12
I used C:\SDL-1.2.12
3. Modify SDL.cabal file from hsSDL distribution.
A. There is a line:
Extra-Libraries: SDL
Change it to:
Extra-Libraries: SDL.dll SDLmain
B. Add two new lines to the end of the file:
Include-Dirs: C:\SDL-1.2.12\include
Extra-Lib-Dirs: C:\SDL-1.2.12\lib
4. Modify C:\SDL-1.2.12\include\SDL.h
Line 28 there is a line:
#include "SDL_main.h"
Comment this out by changing it to:
/* #include "SDL_main.h" */
(This step is needed so that hsc2hs will later work correctly. hsc2hs works
by generating a C program that generates a haskell program when run.
SDL_main.h uses a preprocessor macro to mangle the program's main function.
This causes hsc2hs to fail)
5. Open a Windows Command Prompt (Start -> Run -> "cmd.exe")
cd into the hsSDL distribution directory and run:
runghc Setup.lhs configure
I got an error at the end, about a missing sh:
...
configure: Using hsc2hs: C:\ghc\ghc-6.6.1\bin\hsc2hs.exe
configure: No c2hs found
configure: No cpphs found
configure: No greencard found
Setup.lhs: Cannot find: sh
I ignored the error, and didn't have any problems.
Next run:
runghc Setup.lhs build
Finally, run:
runghc Setup.lhs install
6. Compile the example program. Run:
cd Examples
ghc --make Test.hs
You should get a Test.exe file.
Before running it, copy the SDL.dll file into the directory. You can find
it here:
C:\SDL-1.2.12\bin\SDL.dll
Now run Test.exe, press spacebar a few times to watch the smiley face jump
around, and finally press Q to quit.
7. Using SDL from GHCi does not seem to work. This is the error I get trying to
run Test.hs from GHCi:
Prelude Main> main
Loading package SDL-0.4.0 ... can't load .so/.DLL for: SDLmain (addDLL: unknown
error)
Peace,
Bit Connor <bit@mutantlemon.com>