A template and tips for building SDL-based haskell apps on mac OSX
root
A template and tips for building SDL-based haskell apps on mac OSX. This expands on hssdl's Examples/MacOSX example.
A special initialisation wrapper is required for SDL apps on OSX, at least with SDL 1.2. See the comments in main.c for more.
Requirements:
You'll need SDL libs installed under /usr/local. There may be other ways, but I've had best success using homebrew:
- install Command Line Tools for XCode from apple
- install homebrew
brew doctor
, clean up/fix your brew installation if neededbrew update
brew install sdl sdl_gfx sdl_image sdl_mixer sdl_sound [--universal]
If you are using the 32-bit binary distribution of GHC, note that brew installs 64-bit libraries by default, which will not work. Either switch to the 64-bit GHC, or add the
--universal
option when installing with brew. And, as of right now the sdl_mixer package does not have this option; you can add it locally withbrew edit sdl_mixer
(copy the required two lines of code frombrew edit sdl
).
Build with ghc:
make
Build and run when source changes with sp: install sp, then
make auto
Build with cabal:
make wrapper
cabal configure
cabal build
Build a releasable cabal package:
make wrapper
cabal sdist
Other notes:
I think I had this working cross-platform at one point. This would be good to do.
Or, will SDL 2.0 (released 2013/06) make all this unnecessary ? We can hope.