Setting up the SDL libraries for Code::Blocks for a Windows CompilerBy Thomas Carriero
This tutorial assumes that you have already set up Code::Blocks and the MINGW compiler in Windows. Now, we will add the SDL graphical libraries, which will enable you to write graphical applications. After you've done this, you can check out our tutorial on SDL (in progress).
I will assume you've installed Code::Blocks in C:\Program Files\CodeBlocks. If you've installed it elsewhere, you will need to substitute the path you installed it instead of C:\Program Files\CodeBlocks.
Step 1: Download SDL libraries
Step 2: Uncompress the downloaded .tar.gz fileIf you do not have an application that can decompress this type of file, you can get one here: http://www.7-zip.org/download.html
You will want to uncompress it into its own folder, so that we can manually copy the files we need into the CodeBlocks folder.
Step 3: Copy the files from the uncompressed folder to your CodeBlocks folderI suggest you start by opening both folders and putting them side by side, with the uncompressed folder on the left.
The left folder should look like this:
The right folder should look like this:
First, double click on the "include" folder in the left window (the uncompressed SDL folder). Move the SDL folder from the left window, into the "include" folder in the right window (the code blocks directory). When you finish doing this, your right window's include folder should look like:
(It's important that you copy the whole SDL folder, and not just the files inside of it.)
Now, go back to the view you had before you moved the SDL folder.
Go to the "bin" folder on the left. Move the SDL.dll file to the "C:\Windows" folder. After you do that, the "C:\Windows\" folder should look somewhat similar to this:
Finally, you'll need to copy the contents of the "lib" folder on the left folder over to the "lib" folder on the right. When you do this step, your right folder should look like this:
Test your installationYour installation should be done at this point, so you can close the folders, and open up Code::Blocks.
Go to File and then New Project. Choose the SDL Application and hit Create. You will need to select a place to put it--I recommend you put it in its own folder. Open the main.cpp file and hit F9.
If you see compilation warnings, then you probably did not install the "include" folder correctly. If it compiles okay, but crashes complaining about SDL.dll, then you did not install the "bin" folder correctly.
Otherwise, you should see the following window pop up, which means that everything is working!