Difference between revisions of "SDL/Windows"
(Added warning about GHC bug, C package and Haskell SDL2 package install instructions) |
|||
Line 1: | Line 1: | ||
− | == How to install |
+ | == How to install SDL2 on a Windows computer == |
+ | |||
+ | Note: when you are using GHC 7.10.2 or earlier, using SDL2 will not be possible; you will get the following message when trying to install a package: |
||
+ | <pre> |
||
+ | <command line>: can't load .so/.DLL for: mingw32.dll (addDLL: could not load DLL) |
||
+ | </pre> |
||
+ | See [https://ghc.haskell.org/trac/ghc/ticket/3242 GHC ticket 3242] |
||
+ | |||
+ | You have to install the C package SDL2 first, then either the Haskell package SDL2 or hsSDL2 |
||
+ | |||
+ | === The C package === |
||
+ | |||
+ | Download the precompiled [https://www.libsdl.org/download-2.0.php SDL2 package] and unzip it to e.g. C:\Libraries |
||
+ | |||
+ | If you want to compile from source, you will need |
||
+ | * [http://sourceforge.net/projects/pkgconfiglite/files/latest/download pkg-config.exe] |
||
+ | * [http://mingw-w64.org/doku.php Mingw-w64] |
||
+ | * [http://sourceforge.net/projects/mingw/files/MSYS/ MSYS] |
||
+ | |||
+ | If you are using SDL 2.0.3, install [https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h the debugged version of SDL_platform.h] in the include directory. |
||
+ | |||
+ | Use the following settings |
||
+ | <pre> |
||
+ | Set LIBRARY_DIR=C:\Libs\SDL2-2.0.3\i686-w64-mingw32 |
||
+ | Set PATH=%LIBRARY_DIR%\bin;%PATH% |
||
+ | Set LIBRARY_PATH=%LIBRARY_DIR%\bin;C:\Programs\MinGW\lib;%LIBRARY_PATH% |
||
+ | Set C_INCLUDE_PATH=%LIBRARY_DIR%\include\SDL2;%LIBRARY_DIR%\include |
||
+ | Set PKG_CONFIG_PATH=%LIBRARY_DIR%\lib\pkgconfig;%PKG_CONFIG_PATH% |
||
+ | Set PKG_CONFIG_PATH=C:\Programs\GTK\lib\pkgconfig\;%PKG_CONFIG_PATH% |
||
+ | </pre> |
||
+ | |||
+ | |||
+ | === The Haskell package SDL2 === |
||
+ | |||
+ | <pre> |
||
+ | cabal install sdl2 |
||
+ | </pre> |
||
+ | |||
+ | |||
+ | === The Haskell package hsSDL2 === |
||
Download and [[How to unpack a tar file in Windows | unpack]] the SDL2 development libraries (the .tar.gz files with mingw in the name) from: |
Download and [[How to unpack a tar file in Windows | unpack]] the SDL2 development libraries (the .tar.gz files with mingw in the name) from: |
Revision as of 11:08, 8 December 2015
How to install SDL2 on a Windows computer
Note: when you are using GHC 7.10.2 or earlier, using SDL2 will not be possible; you will get the following message when trying to install a package:
<command line>: can't load .so/.DLL for: mingw32.dll (addDLL: could not load DLL)
See GHC ticket 3242
You have to install the C package SDL2 first, then either the Haskell package SDL2 or hsSDL2
The C package
Download the precompiled SDL2 package and unzip it to e.g. C:\Libraries
If you want to compile from source, you will need
* pkg-config.exe * Mingw-w64 * MSYS
If you are using SDL 2.0.3, install the debugged version of SDL_platform.h in the include directory.
Use the following settings
Set LIBRARY_DIR=C:\Libs\SDL2-2.0.3\i686-w64-mingw32 Set PATH=%LIBRARY_DIR%\bin;%PATH% Set LIBRARY_PATH=%LIBRARY_DIR%\bin;C:\Programs\MinGW\lib;%LIBRARY_PATH% Set C_INCLUDE_PATH=%LIBRARY_DIR%\include\SDL2;%LIBRARY_DIR%\include Set PKG_CONFIG_PATH=%LIBRARY_DIR%\lib\pkgconfig;%PKG_CONFIG_PATH% Set PKG_CONFIG_PATH=C:\Programs\GTK\lib\pkgconfig\;%PKG_CONFIG_PATH%
The Haskell package SDL2
cabal install sdl2
The Haskell package hsSDL2
Download and unpack the SDL2 development libraries (the .tar.gz files with mingw in the name) from:
- http://www.libsdl.org/download-2.0.php
- http://www.libsdl.org/projects/SDL_image
- http://www.libsdl.org/projects/SDL_ttf
- http://www.libsdl.org/projects/SDL_mixer
Copy the bin, lib, include and share directories from the packages to a common directory, like C:\Libraries. If you downloaded SDL 2.0.3, replace the header file include/SDL_platform.h with the debugged version
Set environment variables like this:
- To help consistency in the environment variables, we first do:
Set LIBRARY_DIR=C:\Libraries
- then:
Set PATH=%LIBRARY_DIR%\bin;%PATH% Set LIBRARY_PATH=%LIBRARY_DIR%\lib Set C_INCLUDE_PATH=%LIBRARY_DIR%\include\SDL2;%LIBRARY_DIR%\include
If you don't have git yet, install it. Go to a directory where you want the Haskell library source code installed and fetch the Haskell libraries:
git clone https://github.com/Lemmih/hsSDL2 git clone https://github.com/jdeseno/hs-sdl2-image git clone https://github.com/osa1/hsSDL2-ttf git clone https://github.com/jdeseno/hs-sdl2-mixer
If you want to use a cabal sandbox:
cabal sandbox init
Install the Haskell packages:
cabal install .\hsSDL2 cabal install .\hs-sdl2-image cabal install .\hsSDL2-ttf cabal install .\hs-sdl2-mixer
If you get any of the messages:
cabal: Missing dependency on a foreign library: * Missing (or bad) header file: SDL_mixer.h
configure: error: *** SDL not found! Get SDL from www.libsdl.org.
you should check if all installation steps were done properly.