SDL 1.2 isn't covered here. It can be installed on legacy platforms that SDL2 doesn't support, such as Mac OS 9 or Windows 95, but settling for 1.2 would not be a drop-in replacement for 2.0. Some of these installation instructions happen to work with 1.2, however, on the platforms we cover.
SDL 2.0, unlike 1.2, uses the zlib license, which means you can build a static library linked directly to your program, or just compile SDL's C code directly as part of your project, without requirements to publish your source code, etc. However, we encourage you to not statically link for various technical and moral reasons (see docs/README-dynapi.md), and won't cover the details of how to in this document. You may not statically link SDL 1.2 in most cases due to its LGPL licensing, but you should really stop using SDL 1.2 anyhow.
Debian-based systems (including Ubuntu) can simply do sudo apt-get install libsdl2-2.0-0 to get the library installed system-wide, and all sorts of other useful dependencies, too. sudo apt-get install libsdl2-dev will install everything necessary to build programs that use SDL. Please see docs/README-linux.md for a more complete discussion of packages involved.
Red Hat-based systems (including Fedora) can simply do sudo dnf install SDL2 to get the library installed system-wide, or "sudo dnf install SDL2-devel" to get headers and other build requirements ready for compiling your own SDL programs.
The last command says "sudo" so we can write it to /usr/local (by default). You can change this to a different location with the --prefix option to the configure script. In fact, there are a LOT of good options you can use with configure! Be sure to check out its --help option for details. SDL tries to do the right thing by default, though, so you can usually get away with no options at all. "make" could be "make -j4" or whatever if you have more than one CPU; SDL can safely be built in parallel across all the CPU cores you have available to you. A good rule of thumb for Linux is the number of cores plus two, so you use all the processing resources possible, and if a process or two is competing for the disk, those two extra jobs might be able to put the otherwise-idle CPU cores to work in the meantime (so on a four-core system? Try "make -j6".)
An alternative to the configure script is the CMake project file. It works on similar principles to the configure script. CMake does not provide you with a --help option to show all available configuration options, but it provides a GUI to change configuration options: cmake-gui. There is also ccmake for the console aficionados.
SDL on Unix should only link against the C runtime (glibc). Every thing else it needs will be dynamically loaded at runtime: X11, ALSA, d-bus, etc. This means it is possible to build an SDL that has support for all sorts of targets built in, and it will examine the system at runtime to decide what should be used (for example, if Xlib isn't available, it might try to load Wayland support, etc). In that respect, if you plan to ship the SDL binary that you build, it is to your benefit to make sure your system has development headers for as many targets as possible, regardless of what you plan to personally use, so your final library is as robust as possible. See docs/README-linux.md for more details.
If you are shipping a Linux game on Steam, or explicitly targeting SteamOS, the system is guaranteed to provide SDL. The Steam Client will set up the dynamic loader path so that a known-good copy of SDL is available to any program that needs it before launching a game. Steam provides both SDL 1.2 and 2.0 in this manner, for both x86 and amd64, in addition to several add-on libraries like SDL_mixer. When shipping a Linux game on Steam, do not ship a build of SDL with your game. Link against SDL as normal, and expect it to be available on the player's system. This allows Valve to make fixes and improvements to their SDL and those fixes to flow on to your game.
We are obsessive about SDL2 having a backwards-compatible ABI. Whether you build your game using the Steam Runtime SDK or just about any old copy of SDL2, it should work with the one that ships with Steam.
SDL currently provides Visual Studio project files for Visual Studio 2010 or later in various flavors, and the CMake files can often generate project files for other Windows compilers. Win32 and Win64 are both supported, and we support any Windows version back to Windows XP.
As of SDL 2.0.3, the codebase still compiles on Cygwin and MingW32, but we expect these to stop working in the future. MingW64 is still supported (and despite the name, can also build 32-bit binaries). Note that the Visual Studio builds produce standard Windows .DLLs, which are usable with any compiler that can link to them, and we care about making sure the public SDL headers work with any compiler, but making sure SDL itself builds with some of these compilers has become time-consuming and messy for diminishing returns. For simple fixes, we will always accept patches, though!
On Windows, SDL does not depend on a C runtime at all, not even for malloc(). This means it's possible to build SDL with almost any Windows compiler and have it work with a program built with any other. Furthermore, it means that SDLmain (the small static .lib file that optionally provides WinMain()) does not force you to deal with Debug vs Release builds in your app, since it doesn't need either a Debug or Release C runtime. One .lib should work everywhere.
You can build for macOS "the Unix way" with the configure or CMake scripts, and Xcode projects are also provided. You can ship an SDL.framework, or just build the .dylib file and ship it with an appropriate install_name to ship beside your program's binary.
This will accomplish two important things. First, it will build an x86-64/arm64 "universal" version of the library. Second, it will make sure the library is compiled and linked with a good -mmacosx-version-min option for each arch, so that the library will work on any macOS version back as far as possible, regardless of what version of Xcode you compiled on and what platform SDK. Without this, you are likely to build something that only works on the latest version of macOS!
SDL2 has dropped support for PowerPC Macs and Mac OS X versions older than 10.6 (SDL 1.2 still supports PPC and 10.0, though). That being said, some small changes can make it work, but they make the codebase uglier for small gains, and it's getting hard to find older macs to test on, so we probably will not be restoring official support.
SDL supports iOS 6.1+ and ships with iOS project files (in the Xcode-iOS directory) which will produce a static library. This library should be usable across all supported iOS devices (including iPhones, iPods, and iPads), and the emulator. Just load the Xcode project and click "Build."
If you want to build SDL on your Raspberry Pi directly, just build it "the Unix way," as the RPi is, more or less, a standard Linux system. It can be built with X11 support, and also can do OpenGL ES rendering directly to the screen without an X server, to save resources. In theory, Wayland could also be supported, but at the time of this writing it doesn't configure/compile correctly (send patches!).
SDL can target Google Chrome's Native Client, aka "NaCL", which is, more or less, native binaries as web apps. We've tested with "PNaCL" specifically, but you can probably make this work with other compilers too.
SDL, as of 2.0.4, can be built with Emscripten, so you can compile your SDL2-based C/C++ application to JavaScript/asm.js/WebAssembly, and render with OpenGL ES 2 (which becomes WebGL calls in the end). This port is currently considered experimental, but is already very promising; Humble Bundle is shipping several games as web apps that use it.
This port is generally built "the Unix way," but with a little wrapper script over the configure script or CMake to smooth out some quirks. At the end, you should have a libSDL2.a static library to link against your Emscripten-compiled app.
Also note that Emscripten has a simple implementation of SDL 1.2's API built in. This is written by hand in JavaScript and is unrelated to the SDL codebase. The SDL2 port literally uses Emscripten to compile SDL's C code and link it to your app.
SDL2 runs on the Nintendo Switch! There are commercial games shipping with this port. This port is kept in a separate repository, but is available for free, under the zlib license, to anyone that is under NDA for Switch development with Nintendo. Please contact Ryan (icculus at icculus dot org) for details.
If your favorite system is listed below, we aren't working on it. If you send reasonable patches, we are happy to take a look, though! SDL 1.2's API and feature set is different than SDL 2 (dramatically different in some cases), but it's possible that 1.2 still supports some of these systems.
SDL2 does not currently support (most of) these platforms, but we'd really like to! If you work for Sony, Microsoft, or Nintendo, we would like to port SDL2 to these platforms and provide support to registered developers in a separate repository. Please get in touch with us!
hi SDL team,
Now we want to using SDL2 in windows 10 arm platform, and I try to build SDL2 win10 arm version by myself. but i got many build errors.
So i want to ask does SDL2 official support win10 arm platform? if not, Is there a support plan about this?
Regards
DU
I can't seem to find anything to configure the SDL building process to target the i386 CPU (Windows 95 minimum CPU). My application uses SDL and SDL_gfx. I can target i386 with my application itself fine, but SDL doesn't seem to have an option for that?
This will produce machine instructions that can run on 386, but will optimize for all CPUs. If you want a build that specifically optimizes for 386 (and may runs slow on other CPUs), replace "generic" with "i386".
Edit: I've compiled SDL and called make install to install the library into the correct location? Now trying to compile SDL_gfx using the new SDL library (same method) and then my application using it again.
c80f0f1006