Setting Up SDL2 with Visual Studio 2012 and 2013

I have confirmed that everything below works for Visual Studio 2013.
Links updated to the latest release (2.0.3).

The Simple DirectMedia Library (SDL) version 2 has been released after a long time in development. It seems that the author has more time on his hands and more corporate backing from his new position at Valve Software. I’ve heard that they use SDL for various small time projects that don’t require heavy rendering. Even so, SDL does a formidable job at making things easy.

I wrote this guide under the following setup, but I’m sure that it can be applied to other version of Windows (and maybe even Visual Studio).


Anyway, try your setup and let me know how it goes. Follow these steps to get all setup and ready to code:

  1. Download the development libraries
  2. Download the 32-bit binary or the 64-bit binary
  3. Extract both zips to a convenient location
  4. Open Visual Studio and create an empty C++ project
  5. Right click the created project in the Solution Explorer, go to Properties
  6. Click VC++ Directories under Configuration Properties
  7. In the “Include Directorires” line, add the include directory from the extracted development library
  8. In the “Library Directories” line, add the libx86 directory from the extracted development library
  9. Click Linker –> Input under Configuration Properties
  10. In the “Additional Dependencies” line, add “SDL2.lib” and “SDL2main.lib” strings
  11. Click Linker –> System under Configuration Properties
  12. In the “SubSystem” line, change the selection to WINDOWS(/SUBSYSTEM: WINDOWS)
  13. Finally, copy the SDL2.dll file from the extracted 32-bit binary folder to your project’s output directory alongside the executable

OK, the ugly project setup is finished. Now we can have some fun with coding. Now add a new cpp file with this code.

Compile and run the application to see if any errors are generated. All we did in this code was initialize SDL and immediately quit. If you saw any strange errors, then something is either wrong with the project properties described above, or you’re missing some SDL dependencies.

Comments 12

Leave a Reply

Your email address will not be published. Required fields are marked *