Saturday, December 27, 2008

(0) Comments

Setting up SDL in Dev C++

welcome to infomix.blogspot.com

1)First thing you need to do is download SDL headers and binaries.
You will find them on the SDL website, specifically on this page.

Scroll Down to the Development Libraries section and download the Mingw32 development library


Open gz archive and there should be a *.tar archive inside.
Open the *.tar and there should be a folder inside of that.
Copy that folder anywhere you like. For these tutorials I'm putting it in C:\

2)Start up Dev C++ and go to the Compiler Options.

3)Go to the Directories Tab and then the C++ include tab. Click the folder icon:

then add in the include directory from the SDL folder you extracted.




4)Then under the libraries tab add in the lib directory from the SDL folder:


5)Now take the SDL.dll from the SDL folder you extracted (it should be inside the bin subfolder) and copy it to where you're going to make your project. You're going to put SDL.dll in the same directory as your exe when you compile it.

Alternatively, you can copy SDL.dll to C:\WINDOWS\SYSTEM32 so your SDL app will find SDL.dll even if it's not in the same directory. 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. Generally you want to have your SDL.dll in the same directory as your executable developing and you'll always want to have SDL.dll in the same directory as the exe when distributing your app.

6)Now start up Dev C++ and start a new empty project.

7)Go to the project options.

8)Under the General tab, set type to Win32 GUI.
This is to make sure a console window does not pop up.

9)Under the Parameters tab, paste:
-lmingw32 -lSDLmain -lSDL
in the linker.

10)Add source new source file to the project.

11)Paste the following code into the new source file:
#include "SDL/SDL.h" int main( int argc, char* args[] ) { //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); //Quit SDL SDL_Quit(); return 0; }
12)Now Compile. Save the new source file if necessary and make sure SDL.dll is in the same directory as the executable or in C:\WINDOWS\SYSTEM32. If there are no errors, you're finished. Otherwise go back and make sure you didn't skip a step.
Also, In the archive you just downloaded there's a subfolder called "docs". It contains the SDL documentation.

I highly recommend that you extract them somewhere and keep it for reference.

0 Responses to "Setting up SDL in Dev C++"

Post a Comment