SDL 2.0.0 supports Windows XP, Windows Vista, Windows 7, 8, 10 and 11.
SDL can be built with ICC, Visual C++, Cygwin, MinGW, and Dev-C++.
For the latest information see the page about Installation.
For some reason, archives created on Linux have the "Encrypted" property set when unpacked on Windows 2000. This can be unset by pushing Advanced from the General tab of the properties window and unchecking Encrypt contents check box. The files can then be copied normally.
SDL 1.2 is not officially supported on Windows CE, but some people have successfully built and run SDL applications on Windows CE.
SDL 1.2.5 and newer contain project files and information on building SDL 1.2 for Windows CE. Take a look at the file README.WinCE in the source archive for more information.
There is no support for Windows CE in SDL 2.0.
Read the file "VisualC.html" included with both the SDL Visual C++ development archive, and the SDL source archive.
You need to install the platform SDK, as described here: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
SDL is dynamically linked with the multi-threaded version of the Microsoft Visual C runtime. You need to edit your project settings, go to the C++ language tab, change the listbox to "Code Generation" settings, and then change the runtime library to "Multi-threaded DLL". Make sure you do this with all projects that you link into your application.
This happens with Visual C++ 5, if you use the prebuilt SDL library and have not updated to the latest service pack.
You need to pass the SDL_INIT_NOPARACHUTE flag to your calls to SDL_Init() to make the msvc debugger work. Otherwise the debugger will be unable to trace exceptions, and other debugging features like run to cursor won't work.
The DirectX drivers have a system lock while you have video surfaces locked. To avoid this, you can set the video driver to GDI by setting the SDL_VIDEODRIVER environment variable to: windib. Since this changes video and mouse/keyboard input drivers, you'll see a difference in performance and features available, but you'll be able to debug your application more easily.
Link your application with the Console subystem instead: `/SUBSYSTEM:CONSOLE`.
Alternatively, you can use the Win32 API to conditionally create a console: ```c
static void create_console(void) {
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
int main(int argc, char *argv[]) {
if (strcmp(argv[1], "--debug") == 0) {
create_console();
}
/* ... Enter your secret sauce here */
return 0;
} ```
You can build and use SDL with gcc natively using either Cygwin, MSYS2 or MinGW, or you can build a gcc cross-compiler targeting Windows from another platform. Setting up these environments is documented at: http://www.libsdl.org/extras/win32/gcc.html Once the build environment is set up, you can build your applications as though you are on an Unix. See the Linux FAQ for more details on building applications in this environment.
Try the Dev-C++ tutorial available at: http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut1 (Archive). If you have problems, please contact the author of the tutorial.
There are also step by step instructions at: http://docs.deninet.com/sdl_on_dev_c.htm (Archive)
Choose "gui application" instead of "console application" when compiling for Vista.
When using pkg-config, or certain SDL2 CMake configuration scripts, `-mwindows` is always added as a link option. This option instructs the Windows loader to start your application though `WinMain` and don't show a console window.
The method to remove `-mwindows` depends on your build system: For CMake build systems, set the `SDL2_NO_MWINDOWS` CMake variable to remove `-mwindows` from the link options prior to calling `find_package(SDL2)`. For pkg-config, use `$(pkg-config sdl2 --libs-only-L --libs-only-l)` instead. For sdl2-config, use `sed` to remove `-mwindows`: `$(sdl2-config --libs | sed -E s/-mwindows//)`
When not adding `-mwindows`, you need to make sure `SDL_SetMainReady()` is called before `SDL_Init` because the `WinMain` symbol in `SDL2_main` is not used anymore.
You can also conditionally create a console. See the corresponding FAQ item of Visual C++ above.
Make sure that you are declaring main() as:
#include "SDL.h"
int main(int argc, char *argv[])
You should be using main() instead of WinMain() even though you are creating a Windows application, because SDL provides a version of !WinMain() which performs some SDL initialization before calling your main code. If for some reason you need to use !WinMain(), take a look at the SDL source code in src/main/win32/SDL_main.c to see what kind of initialization you need to do in your !WinMain() function so that SDL works properly.
Warning/error messages that might also be fixed by this are: - found main and WinMain; defaulting to /subsystem:console - found both wmain and main; using latter".
Under Visual C++, you need to link with SDL2main.lib. Under the gcc build environments including Dev-C++, you need to link with the output of "sdl2-config --libs", which is usually: -lmingw32 -lSDL2main -lSDL2. While using vcpkg SDL2main.lib is moved to the manual-link folder and needs to be consumed manually for more information see vcpkg's integration docs.
When you're building using CMake, make sure to add WIN32 to add_executable. When using MinGW, add -mwindows to the link options. MSVC users should add /subsystem:windows. clang-cl users should add -Xlinker /subsystem:windows.
When you're compiling with gcc, you need to make sure the output of sdl2-config follows your source file on the command line: gcc -o test test.c sdl2-config --cflags --libs
If you're getting undefined references to functions in SDL2_image or SDL2_mixer, make sure you're actually linking with those libraries as well.