Skip to content

Instantly share code, notes, and snippets.

@573
Created July 14, 2012 18:38
Show Gist options
  • Save 573/3112598 to your computer and use it in GitHub Desktop.
Save 573/3112598 to your computer and use it in GitHub Desktop.
Building hsSDL on Win32
-----------------------
Bit Connor <[email protected]>
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. 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
5. 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.
6. Using SDL from GHCi requires a trick. If you try running Test.hs you will
get this error:
> ghci Test.hs
Prelude Main> main
Loading package SDL-0.4.0 ... can't load .so/.DLL for: SDLmain (addDLL: unknown
error)
To get ghci working, you must make 2 copies of SDL.dll called SDLmain.dll,
and SDL.dll.dll:
copy SDL.dll SDLmain.dll
copy SDL.dll SDL.dll.dll
Now everything should work!
Peace,
Bit Connor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment