Code::Blocks & SDL

Started by
3 comments, last by endless11111 11 years, 11 months ago
I want to make Code::Blocks work with SDL.

I downloaded Code::Blocks 10.05 (the package with MinGW/CGG) then followed these instructions http://wiki.codeblocks.org/index.php?title=Using_SDL_with_Code::Blocks#The_Process (downloaded SDL-devel-1.2.15-mingw32 instead 1.2.9 since that one was the newest).
Next, I created a project (selected "SDL project") and... it asks for "Please select SDL's location". I tried to put there the path to the whole SDL package (but then what was the point of copying these files manually to MinGW in previous steps?) but it still says "Can't locate SDL.h" (it's still the create project stage, no compilation or linking error).

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Advertisement
I think that the only thing you'd need to copy to either application directory or mingw/bin is SDL.dll. The following process worked for me after with SDL 1.2.15 development libraries. My CB might be a bit old (build 7289), but I doubt it would make a difference:

1. Set sdl variable BEFORE creating an SDL project. For me it crashes CB entirely or just did funny business in earlier versions.
To set sdl variable go to Settings->Global Variables, click New that's on the same line with Current Variable. Name it sdl. Set base to the directory where you unpacked the SDL package.
2. Create new SDL project with default values.
3. Build = if it works - great! If it doesn't then check under Project Options->Search Directories->Compiler and rename $(#sdl.include)\SDL to $(#sdl.include). Try again.

(downloaded SDL-devel-1.2.15-mingw32 instead 1.2.9 since that one was the newest).

Just to be sure it'll work right you should probably restart the process and use the version that they suggested in the guide and see if that changes anything. If it works with 1.2.9 just stick with that one for now till you find a way to make CB work with the newest version.
Got it working (needed to copy sdl*.h files outside the SDL directory), thanks.

Now, I wonder. I managed to add SDL_ttf similar way (global options then SDL_ttf to linker and $(#sdl_ttf.lib/include) to search directories). But the curious thing, for SDL to work there needs to be SDL.dll in MinGW bin directory, SDLmain and sdl.dll listed on linker page. But for SDL_ttf there only needs to be SDL_ttf on linker page (the dll is somehow automaticly added from the libs directory without setting anything)... I tried to do the same thing with SDL (copied sdl.dll to the SDL libs directory) but it is not working.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

You should go to Lazy foos site, he has tutorials on how to set up and start sdl on code blocks and set up extensions.
Here is how to set up sdl -- http://lazyfoo.net/SDL_tutorials/lesson01/windows/index.php
and extensions, this is for SDL_image but it works for all the other extensions. -- http://lazyfoo.net/SDL_tutorials/lesson03/windows/index.php

This topic is closed to new replies.

Advertisement