User forums > Using Code::Blocks

N00b needs help getting C::B to see SDL libraries =P

(1/2) > >>

4matsy:
Hey there, fellow coders. C::B looks like an impressive piece of work indeed, and I look forward to many (relatively) happy late nights of programming in the future with its help. :D

...if I can get any external libraries working. :P



Okay, so I downloaded and installed C::B, MinGW Windows binaries, and SDL Windows binaries, and they're all living happily in their own lil' directories:
C:\cpp\codeblocks
C:\cpp\mingw\3.1.0
C:\cpp\sdl\SDL-1.2.9

So after having C::B auto-detect the MinGW install, I decided to go try out some of the example projects included with C::B.

The "Console Application" project works like a charm, compiling and running without a hitch.

The "SDL Application" example, on the other hand, is where I run into trouble. :P

A bunch of errors come up regarding main.cpp, saying "(insert SDL-related function here) undeclared"; preceding all these is "main.cpp:6:17: SDL.h: No such file or directory", pointing of course to the "#include <SDL/SDL.h>" line.

Apparently something somewhere doesn't know where the SDL libraries are located. Well, that doesn't seem too hard to fix, or so I thought. :roll:

The thing is, I know that somehow I've got to tell the compiler and/or linker where to look for SDL, but don't really know how to accomplish this.
I've already tried putting various directories (usually C:\cpp\sdl\SDL-1.2.9\lib) in the list under Project -> Build options -> Directories -> Linker, but that isn't doing the trick.



I get the feeling I've missed something ridiculously obvious here...does anyone have an idea what that might be?

Thanks in advance. :)

tiwag:

--- Quote ---A bunch of errors come up regarding main.cpp, saying "(insert SDL-related function here) undeclared"; preceding all these is "main.cpp:6:17: SDL.h: No such file or directory", pointing of course to the "#include <SDL/SDL.h>" line.

--- End quote ---
this is a compiler error  so the compiler cant find the SDL.h file. therefore add the directory to the
Project -> Build options -> Directories -> Compiler
list of directories where the compiler should search for files - isn't that easy ?
be shure, that you give the path to below the SDL directory, if you want  to include <SDL\SDL.h>


--- Quote ---I've already tried putting various directories (usually C:\cpp\sdl\SDL-1.2.9\lib) in the list under Project -> Build options -> Directories -> Linker, but that isn't doing the trick.

--- End quote ---
that is ok and necessary too for the linker !!

takeshimiya:
Go to Settings->Compiler Settings->Directories tab.

In the compiler tab, add C:\cpp\sdl\SDL-1.2.9\include\SDL.
In the linker tab, add C:\cpp\sdl\SDL-1.2.9\lib.

And in your main.cpp, replace the #include <SDL/SDL.h> by #include <SDL.h> which is the correct way to do it.

Hope that helps :)

EDIT: tiwag won me :P

tiwag:

--- Quote from: Takeshi Miya on January 12, 2006, 08:54:18 am ---Go to Settings->Compiler Settings->Directories tab.

In the compiler tab, add C:\cpp\sdl\SDL-1.2.9\include\SDL.
In the linker tab, add C:\cpp\sdl\SDL-1.2.9\lib.

--- End quote ---
i prefer not to put these things globally because with time you maybe have several versions of the same library
and some of your older apps compile well only with older versions - see wxWidgets as good example for it.
So if you want keep your apps compiling as they were - it is a good advice to put all of your pathes needed for
linker and compiler and anything else what's needed to build your app into your project-information.
This initially is maybe a little bit more work, but saves you a lot of work in the future.


--- Quote ---And in your main.cpp, replace the #include <SDL/SDL.h> by #include <SDL.h> which is the correct way to do it.

--- End quote ---
maybe it is a matter of taste, but i would let it be included as <SDL\sdl.h> and only give the right path that this works (no path necessary if copying the SDL header directory in your global mingw\include directory for example.
this way you see on the first sight, from which library your included headers come (if they have not a so obvious name than sdl.h :) )

mandrav:
Look no further: Using SDL with Code::Blocks.

Navigation

[0] Message Index

[#] Next page

Go to full version