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).
- Windows 8 Professional
- Visual Studio 2012 and 2013 Professional
- SDL2 (as of Sept 4, 2013) (http://www.libsdl.org/download-2.0.php)
Anyway, try your setup and let me know how it goes. Follow these steps to get all setup and ready to code:
- Download the development libraries
- Download the 32-bit binary or the 64-bit binary
- Extract both zips to a convenient location
- Open Visual Studio and create an empty C++ project
- Right click the created project in the Solution Explorer, go to Properties
- Click VC++ Directories under Configuration Properties
- In the “Include Directorires” line, add the include directory from the extracted development library
- In the “Library Directories” line, add the libx86 directory from the extracted development library
- Click Linker –> Input under Configuration Properties
- In the “Additional Dependencies” line, add “SDL2.lib” and “SDL2main.lib” strings
- Click Linker –> System under Configuration Properties
- In the “SubSystem” line, change the selection to WINDOWS(/SUBSYSTEM: WINDOWS)
- 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.
int main(int argc, char* args)
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.… Read more