Simple Directmedia Layer for C/C++

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games.

SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. Support for other platforms may be found in the source code. SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.

Setting up SDL in Eclipse for C/C++

  • Download SDL headers and binaries. You will find them on the SDL website. Extract the archive using any archive utility.

  • Copy the contents of the lib subfolder to the MinGW lib folder. The MinGW lib folder should be at C:\MinGW\lib.
  • After that, open the include subfolder in the archive and extract the folder named "SDL2" to the MinGW include folder, which should be at C:\MinGW\include.
  • Copy the SDL2.dll from the archive to the same directory as your exe when you compile it. Alternatively, you can copy SDL2.dll to C:\WINDOWS\SYSTEM32 so your SDL app will find SDL2.dll even if it's not in the same directory. If you're using a 64bit version of Windows, you' will have to copy the dll in C:\Windows\SysWOW64. The problem with this method is if you have multiple SDL apps that use different versions of SDL, you'll have version conflicts. If you have SDL 1.2.8 in SYSTEM32 when the app uses 1.2.13 you're going to run into problems. It is better to have your SDL2.dll in the same directory as your executable while  developing. 
  • Now start up Eclipse and start a new project. 
  • Go to the project properties. Go to the C/C++ Build menu, then the Libraries submenu. In the Libraries submenu click add.
  • Add mingw32, SDLmain and SDL Libraries. Do it in this exact order or it won't work.