(→‎Install and execute SDL2 on a Windows computer: Added a link to "Windows SDL2 is now almost painless via stack")

Line 1:

Line 1:

== Install and execute SDL2 on a Windows computer ==

== Install and execute SDL2 on a Windows computer ==

+

+

If you want to install SDL2 with [[stack]], see [https://www.reddit.com/r/haskellgamedev/comments/4jpthu/windows_sdl2_is_now_almost_painless_via_stack/ "Windows SDL2 is now almost painless via stack"], otherwise, see below.

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:

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:

Open a command prompt and type 'C:\Windows\System32\where.exe ghc.exe'.
'where' will return all ghc.exe files in the %PATH% environment variable.

If your version of GHC is installed in 'C:\Program Files', e.g.

$ where ghc
C:\Program Files\Haskell Platform\7.10.3\bin\ghc.exe

that means you are using a 64 bit version of GHC.

If you also have GCC installed and plan on compiling or linking SDL2 C files in the future, you should probably uninstall 64-bit GHC and install the 32-bit version (Unless you also install(ed) 64-bit GCC).

This because GCC and GHC both hapily accept library files for the wrong architecture, to then error because of invalid linkage. This means you can only have one architecture at a time in the %PATH%. You might be able to get around this restriction with some symlinks, but it's really not worth the effort.

Note that SDL, as many others (including GHC and GCC), use a very confusing naming scheme:

32-bit becomes i686-w64-mingw32

64-bit becomes x86_64-w64-mingw32

The rest of this page asumes you want to install SDL2-2.0.4 for a 32-bit environment.

Note: You might want make sure all environment variables are correct after installing:

Control Panel -> System and Security -> System -> Advanced system settings -> Environment variables... -> System variables

If the environment variable did not yet exist (as is usually the case with %LIBRARY_PATH%, %C_INCLUDE_PATH% and %PKG_CONFIG_PATH%), the ';%VARIABLE_NAME%' will be included at the end, which might not be desirable (Although it probably won't do any harm).

If no errors are reported, SDL2 is now installed and you should be able to compile, link and execute your programs.

In order to ship your SDL2 product, all you will have to do is to include a SDL2.dll from the correct architecture (The one the program is compiled with). You can do this freely by the license of SDL. By placing the DLL in the same directory as the executable, everything should now run as expected.

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