Skip to content

Installation instructions for template Haskell project

efinky edited this page Mar 4, 2014 · 2 revisions

Install Haskell platform

Get the msys base environment

  • Download mingw-get-setup.exe from here: http://www.mingw.org/wiki/Getting_Started and run it

  • You should only have to select the msys-base meta-package. (which will install several other packages) Then from the menu: "Installation" -> "Apply Changes" And then press the "Apply" button to download and install

  • Once the changes are applied, you can close the installer

  • Take a note of the install path, it's ususally C:\MinGW unless you change it. We'll call this the mingw-install-path. (even though we're only installing msys)

Get SDL development libraries

  • Download the SDL-1.2 Win32 mingw32 development libraries from here: http://libsdl.org/download-1.2.php (they're usually at the bottom):

  • Extract them to some directory. We'll call this the SDL-install-path

  • In the extracted directory there should be a file: bin/sdl_config open it in a text editor

    • There should be a: prefix=/usr/local/cross-tools/i686-w64-mingw32 replace it with your SDL-install-path, but make sure you replace all the backslashes in the path with for slashes, and remove the colons. So if your SDL-install-path was: C:\Developer\SDL-1.2.15 you'd put /c/Developer/SDL-1.2.15

    • If your SDL-install-path has spaces in it, you lose two nerd points and should go move it to a path without spaces.

  • Add the directory containing sdl_config to your path

  • Add SDL-install-path\lib to your path

Install SDL Haskell bindings

  • Run: mingw-install-path\msys\1.0\msys.bat

    • (Which will probably be: C:\MinGW\msys\1.0\msys.bat)
    • This should open a shell window
  • In the shell window, type: cabal update

  • If this is a fresh Haskell platform install you'll probably be prompted to update cabal-install, DON'T.

  • Then type: cabal install sdl —-extra-include-dirs=SDL-install-path/include —-extra-lib-dirs=SDL-install-path/lib

    • For example: cabal install sdl —-extra-include-dirs=/c/Developer/SDL-1.2.15/include —-extra-lib-dirs=/c/Developer/SDL-1.2.15/lib

Get SDL_Image development libraries

  • Download SDL_image windows development libraries here: http://www.libsdl.org/projects/SDL_image/release-1.2.html. They'll be named something like: SDL_image-devel-1.2.12-VC.zip

  • Extract it to a directory

    • we'll refer to this directory as SDL_image-install-path
  • Take SDL_Image.h from SDL_image-install-path/include and copy it to SDL-install-path/include/SDL

  • Take everything in SDL_image-install-path/lib/x86 and copy it to SDL-install-path/lib

    • Note the x86 in the above path, don't copy the wrong one.
  • Once we get everything working you can delete the SDL_image-install-path as we've copied everything we need out of it.

Installing SDL-image Haskell bindings

  • In a directory of your choice (but from the msys shell) do a cabal unpack SDL-image

    • This will download and unpack the SDL-image package from hackage
  • Open SDL-image-0.6.1\Graphics\UI\SDL\Image\Version.hsc in an editor

    • underneath #include “SDL_image.h” add:

      #ifdef main
      #undef main
      #endif

  • From the msys shell cd into the unpacked SDL-image directory and run: cabal install --extra-include-dirs=SDL-install-path/include/SDL --extra-lib-dirs=SDL-install-path/lib

    • (note this is slightly different command from the SDL cabal install, though it looks similar)

Building template SDL Haskell project

Now if you want you can switch back to a normal windows cmd shell

  • In a directory of your choosing do a git clone https://github.com/Manticore/haskell-sdl-template

  • Then cd into that directory and do:

    • cabal install --only-dependencies
    • cabal configure
    • cabal build
  • Copy image.png to dist\build\Resources (You'll have to create the Resources dir)

  • Run dist\build\sdltemplate\sdltemplate.exe

TADA!

Clone this wiki locally