Sunday, February 26, 2012

How to configure Code::Blocks for SDL


To configure Code::Blocks to be used with SDL, follow these steps:




1. If you don't have the Code::Blocks, download the 10.05 version of it with MingW compiler from the link below. 


2. Download SDL headers and binaries (version 1.2.15 for windows) click on the link below and extract them in to your C drive.


3. Install Code::Blocks.

4. Start the Code::Blocks and go to "Compiler and debugger" in "Settings" menu.


5. Go to "Compiler" tab under "Search directory" and click "Add".

 
6. A window will pop-up and in this window click the browse button. 


7. And browse for the "include" folder inside SDL folder which you have extracted in C and hit "OK". By doing so, we are providing the compiler with the path of all the header files which are written for SDL libraries. And now we can include any of the header file, which are present inside this include folder, into our main program.


 8.you will see this window.


9. Now click on the "Linker" tab under "Search directory" and "Add" the path for the linking libraries as follows


10. Now browse for the "lib" folder inside SDL folder which you have extracted in C drive, as shown



11. Hit "OK". Create a new project (File/New/Project..)


12. Give this project a name and select the storage location for your project files. On the next window click "Finish" to create a new project with the specified name.


13. After clicking "Finish" on the next window, your folder which will be storing your all project files will be created. Now all the files which may be required by your program (which you will be writing) must be kept inside this folder.

14. Next do these settings to prevent console window to appear during execution of your program. Go to "Properties" in "Project" menu.


and select the "GUI application"


15. Now go to the "Compiler and debugger" settings menu again and in "Linker Settings" type:

-lmingw32 -lSDLmain -lSDL
under "other linker options".


16. Now your compiler is fully configured to work with SDL.

17. Now as you will be working with SDL, it's DLL files (SDL.dll) will be required by your compiler to execute your program. So you need put those DLL files inside your Folder, which you have just created in step no. 13. You will find these DLL files in C:/SDL/bin. Copy SDL.dll and put it inside your project folder folder_name/bin/debug (created in step 13).

NOTE: This bin/debug folder will be created after you will write your first program and try to run it, running the program will give you an error and then you need to put this DLL file in bin/debug folder inside your project folder.

NOW YOU ARE ALL SET TO ROCK WITH SDL. ENJOY PROGRAMMING WITH SDL :)
A brief description of DLL:

"A Dynamic Link Library (DLL) is a file of code containing functions that can be called from other executable code (either an application or another DLL). Programmers use DLLs to provide code that they can reuse and to parcel out distinct jobs. Unlike an executable (EXE) file, a DLL cannot be directly run. DLLs must be called from other code that is already executing."

To know more about DLL click on the link below:

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews