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++.
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.
Expand the Linker tree and click on Input. On the Additional Dependices click on Edit.
A box will appear and inside this box we will link the SDL lib files to our project like this
SDL.lib
SDLmain.lib
Click on OK. Now go to System and on the SubSystem drop down choose Windows(/SUBSYSTEM:WINDOWS)
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[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Quit();
return 0;
}
If you folowed all the steps correctly your code should now compile successfully and this means you have configured SDL with Visual Studio 2010.
0 comments :
Post a Comment