Setting up code::blocks to use a library

I am a self taught occasional hobby programmer who wants to get up to speed with C++ and libraries like SDL using CodeBlocks. I do have C code experience having used it on the old MSDOS machines.

The last week I have been trying to set up the CodeBlocks IDE to allow me to write programs using the SDL library and have tried to follow the steps given by various internet sources (without understanding) but I still get compiler "can't find a file" errors but without enough understanding to actually figure out what to do about it.

The question is:
Is there any detailed tutorial on how all this "setting up" works?


closed account (NUj6URfi)
Try the ones here. http://lazyfoo.net/tutorials/SDL/index.php Tutorials for OSes and IDEs + how to use it all! :D Have fun!
Thanks for the fast responses.
The lazyfoo tutorial was one of the tutorials that I tried to follow. The main SDL worked eventually but not the image and ttf extras. And then I added iostream and it failed to be found something that never occurred with my MSDOS C programming efforts. It is only found when I use the console template. The thing is I need to understand how it works not simply follow a set of "setting up" steps without understanding so I can figure out exactly what I am doing wrong.
I just found the learncpp.com before posting this and will see if it helps.
Thanks again.
I used to follow a YouTube tutorial series created by MakingGamesWithBen.
He is currently the Head of a Indie Dev team working on a new voxel game (a.k.a Minecraft Graphics) called Seed of Andromeda.

He actually does a video on EXACTLY what you need. Getting SDL to work in Code::Blocks. Here is the link:
https://www.youtube.com/watch?v=bmjcZv-Itlg

He also does a later tutorial on getting SDL_TTF installed as well (even though he does this video with VS, the general method is the same):
https://www.youtube.com/watch?v=CZPZ7pgPT4E

If you are just starting to get into game development and like the video-style tutorials, then I would HIGHLY recommend the channel to you. His videos are up-to-date with C++11, he is still developing them even though he already has closing in on 100 videos (first a series on general C++, then a series on C++ with OpenGL v3/SDL v2). He also has a 3rd series that will be coming on on how to specifically make a voxel engine with C++.
Oh, and one more plus: unlike almost every other tutorial series on YouTube, he actually responds to the comments on his videos and still actively answers questions.
Though, due to the fact that he is also working on a game, he doesn't respond instantly.

Speaking of which, beside the point, here is a link to the website of the game he is creating in case you are interested:
https://www.seedofandromeda.com/
Last edited on
Ric4
After watching that video I don't feel so bad about having trouble installing the SDL library!!
The reason I was installing SDL and not SDL2 was because both that video and another source warned that SDL2 had a bug and I thought I might as well learn the SDL basics on a bug free version first.
My previous experience many many years ago with C and C++ was on a MSDOS machine and although I think there were graphic libraries available I was capable of writing my own because all you needed was a knowledge of the graphics hardware.

Well, personally I use GLFW paired with OpenGL for graphics.
GLFW is a cross-platform library that is designed specifically to be used for OpenGL. It handles pretty much everything but graphics (for OpenGL, obviously) and audio (there are multiple libraries that can be used for that; the new version of OpenAL should be out soon).
GLFW: http://www.glfw.org/

However, if you don't want to deal with OpenGL, I would also recommend SFML. It is a "true" alternative for SDL (i.e. it offers everything SDL does). It is under a much more active developement, which is a major plus, on top of it handling:
> system (keyInput, etc.)
> window (you need something to see out of)
> graphics (it primarily does 2D like SDL)
> audio (it actually uses OpenAL Soft along with a few other libraries)
> network (though you will only ever need this if you plan on doing multiplayer or automatic updates)

SFML does have 2 downsides, however:
> It uses OpenAL Soft, which is currently licensed under the LGPL license. A great license if you want free software. Horrible license if you want to commercialize anything made off of it. Not saying you can't, you can. I can't give more information on this because I am not a lawyer; the GPL is very cryptic.
> It's support for OpenGL is limited. Here is a quote from the SFML website about using OpenGL:
OpenGL versions above 3.0 are supported by SFML (as long as your graphics driver can handle them), but you can't set flags for now. This means that you can't create debug or forward compatible contexts; in fact SFML automatically creates contexts with the "compatibility" flag, because it uses deprecated functions internally. This should be improved soon, and flags will then be exposed in the public API.


Once that little bug (the second point) is fixed, I would say that there is no real reason why not to use SFML. OpenAL will have a license similar to OpenGL with the release of the new version (which is what I am currently waiting for).

Otherwise, I would still say to try to use GLFW with OpenGL. Rather that, or go with DirectX if you don't mind staying on Windows for a bit.

TL;DR:
Stay away from the outdated SDL; rather worry about the SDL2 bug (which when I used SDL2, I never actually came across), or use an alternative like GLFW or SFML. Or, don't worry about being cross-platform at all and use DirectX.

P.S.
it is RLC, not RIC. My username is all lowercase.

From what I can tell, once OpenAL's new version is released; if you combine GLFW, OpenGL, and OpenAL; you would have a fully functional, complete, truly free to use cross-platform base.

Though, if you wish to get to the point of using both OpenGL and Direct3D as an option within anything you make, you may have to worry about developing your own abstraction layer. That would be a feat, lol.
Last edited on
Topic archived. No new replies allowed.