This guide is about how can you install
sdl libraries for codeblocks:
Steps:
1. Download
SDL Libraries for Mingw, from the internet, or from
here.
2. Extract them somewhere on your drive.
3. Open Codeblocks, and go to Settings -> Compiler -> Search directories -> Compiler, and add there the location of your
SDL library directory and the include folder.
For example:
C:\SDL2-2.0.3\i686-w64-mingw32\include\
4. Go to Settings -> Compiler -> Search directories -> Linker, and add there the location of your
SDL library directory and the lib folder.
For example:
C:\SDL2-2.0.3\i686-w64-mingw32\lib\
5. Go to Settings -> Compiler -> Linker Settings -> Other linker options -> and add the following:
- Cod:
-
-lmingw32
-lSDL2main
-lSDL2
or Go to Settings -> Compiler -> Linker Settings -> Link
Libraries and click Add button, and write in the file window: mingw32 then click ok, press again Add button, write SDL2main then click ok, and press again Add button and write SDL2 and click ok. So it should look like this:
IMPORTANT: it needs to be this exactly order.
After you compile a file be sure you open the executable file in a directory with
SDL.dll which you can find also in the
SDL Library directory/bin.
Also if you encounter messages with missing dll files while trying to open your executable, download them from the internet.
While programming be sure you use: int argc, char** argv, as arguments
for the main function, otherwise you will encounter compilation error something such us: undefined reference to SDL_main, if your compiler is friendly enough.
int main(int argv, char** args)
{
Write here the code.
}
WITHOUT
- Cod:
-
int argv, char** args
THESE PARAMETERS:
- this error will occure.
To use OpenGL add these lines to Settings -> Compiler -> Linker Settings -> Other linker options:
-lglu32
-lOpenGL32
These
libraries are installed by the Codeblocks, so you don't need to download anything.
MISTAKES WHILE LINKING
LIBRARIES:
- this will provide errors.
SDL libraries cannot be linked by browsing, selecting and adding the entire content of SDL2-2.0.3\i686-w64-mingw32\lib\/lib folder.
You can also try:
SDL Libraries for Mingw DevCppSDL Libraries for Microsoft Visual Studio