Lazy Foo' Productions


Setting up SDL Extension Libraries on Code::Blocks 13.12

Last Updated: Feb 2nd, 2015

1) Open up your SDL 2 project and go to project properties.
project properties

2) In order to compile SDL 2 code, we have to tell the compiler to link against the libraries. Go under Linker Settings and paste

-lSDL2_image

into the other linker options field after -lSDL2 and click OK. If you were setting up SDL_ttf, you'd put -lSDL2_ttf and you'd put -lSDL2_mixer for SDL_mixer.
linker
If you get an error where the linker complains about a bunch of undefined references, it means you messed up this step.

3) Now go download the source for lesson 06. Add the source file inside to your project.

Now build. Now you may get an error saying it can't find SDL_image.h. For linux, we'll have to include the SDL headers like this:

#include<SDL2/SDL_image.h>

For SDL_ttf and SDL_mixer, we have to include them like this:

#include<SDL2/SDL_ttf.h>
#include<SDL2/SDL_mixer.h>

Now that you have the extension library compiling, it's time to go onto part 2 of the tutorial.