Web Design,Programming,Mobile,iOS/Android,GameDev,IT Businness,eCommerce,Social Media


Thursday, 27 December 2012

Configuring SDL with Visual Studio 2010


SDL (Simple Direct Media Layer) is a low level api for manipulating pixels to create different UI layouts and even small games. This api is free for download and free for use both for commercial and personal. But many developers face problems when it comes to configuring it with an IDE especially visual studio. Follow these steps and you should be all set up, and in the end we will run sample code to show the result.

First of all go http://www.libsdl.org/download-1.2.php and head down to the Development Library Win32 section and download the zip package for Visual C++.

Configuring SDL with Visual Studio 2010

Extract the zip package anywhere in your desktop. Now this is important. Some people like to configure visual c++ by including directories from other paths. We will not do this. We will do things manually and later one we will only have to include those files without configuring paths and other stuff.
So first of all go to the extracted folder and copy all content from includes folder. Now go to
C->Program Files->Microsoft SDKs->Windows->v7.0A->Include and create a folder here named sdl. As you can see there is a folder called gl wich holds all the opengl library and you should create a folder sdl which will hold all your sdl library. After creating the folder paste the copied files inside this folder.

Now head back to where you extracted the SDL library and go to lib folder and inside you will find two folders x64 and x86. Depending on what configuration you have you will copy the files inside those folders (eg if you have x86 then copy the files inside x86 folder), without SDL.dll file. This SDL.dll file should be included in your projects when you release them. After copying those files head to
C->Program Files->Microsoft SDKs->Windows->v7.0A->Lib and paste here (without creating special folder as we did earlier). And finally one more thing to do before we test things is to copy the SDL.dll file from the extracted lib folder to C->Windows->System32. The SDL.dll file should sit near the executable file or in system32, for our programs to work. Note that if we copy to system32 we dont have to include the SDL.dll file in our projects. But if we want to distribute our program we will have to include the SDL.dll file near executable file or where our programs executable file is.

After doing all these steps launch Visual Studio and create new Visual C++ Empy Project, and name it whatever you like i named it TestSDL. Before doing anything else itn visual studio go to Project->TestSDL Properties and  on the Configurations Dropdown click on All configurations and then expand the Configration Properties tree. Make sure character set is set to Multi-Byte Characer Set. 

Configuring SDL with Visual Studio 2010

Expand the Linker tree and click on Input. On the Additional Dependices click on Edit.

Configuring SDL with Visual Studio 2010

A box will appear and inside this box we will link the SDL lib files to our project like this

Configuring SDL with Visual Studio 2010

Click on OK. Now go to System and on the SubSystem drop down choose Windows(/SUBSYSTEM:WINDOWS) 

Configuring SDL with Visual Studio 2010

If you have followed all these steps then you are ready to write some code and compile. On the Source Files Folder add new cpp file and name it whatever you like. I named it main.cpp. And inside put this code

#include <sdl/SDL.h>

int main(int argc, char *argv[])
return 0;

Configuring SDL with Visual Studio 2010

If you folowed all the steps correctly your code should now compile successfully and this means you have configured SDL with Visual Studio 2010.

Written by

Thank you for taking your time to browse through our blog. We try to build as much rich content base as we can. We focus in modern technologies, computer science design and business.


Post a Comment


© 2013 smartnoob . All rights resevered. Designed by Templateism