Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: XP15EF on April 01, 2010, 09:34:12 pm

Title: Installing libraries
Post by: XP15EF on April 01, 2010, 09:34:12 pm
Hi,

I use codeblocks under OpenSuse-11.2.

I am learning how to program C and use SDL.
SDL was installed and in Yast, I can see :
libSDL-1.2.13 and its devel,
libSDL_image-1.2.7 and its devel.

In Codeblocks, through Project/Build options/Linker settings tab, I added
/usr/include/SDL/SDL.h
/usr/include/SDL/SDL_image.h

My program starts with
#include <stdio.h>
#include <stdlib.h>
#include </usr/include/SDL/SDL.h>
#include </usr/include/SDL/SDL_image.h>

When it comes to
flower=IMG_Load ("flower.png");
I get the error
"undefined reference to 'IMG_Load' "
which means, I think, that SDL_image library is not found.

I don't understand why.
(there is no SDL_image.lib on my system. Is this normal?)

Any hint?
Title: Re: Installing libraries
Post by: stahta01 on April 01, 2010, 10:15:11 pm
Hint:

Compiler uses .h files.

Linker uses other files varies per Operating System. libm.so or libm.a etc. [libm.lib under MS Windows]
m is the math library needed for many c programs.

The "undefined reference" is 99.9% of the time an linker error.

In Code::Blocks it is best to add the library names without the path to the library list.
Note, it is normal to leave off the extension and the lib prefix.
Then, add the search path for the linker.

Note: This is an basic programming info; so the thread may be locked for violating site guidelines.

Tim S.

Title: Re: Installing libraries
Post by: stahta01 on April 01, 2010, 10:18:06 pm
I don't understand why.
(there is no SDL_image.lib on my system. Is this normal?)

Unless you are using Visual Studio under Linux; Linux does NOT use .lib extension. MS Windows does.

Tim S.
Title: Re: Installing libraries
Post by: stahta01 on April 01, 2010, 10:25:01 pm
As I suggest to ALL newbies; turn on FULL Compiler Logging

http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

And, post questions not related to Code::Blocks on sites that support beginners questions.

Tim S.