Makefile error including SDL - [NOT RESOLVED]

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Makefile error including SDL - [NOT RESOLVED]

Post by sg57 »

Im using SDL as a backbone for both sounds and textures, and Im getting undefined references to jpeg and png calls from cygwin when compiling. So i go and set it up by including:

Code: Select all

-lSDL_image -lSDL_mixer -lpng -lz -ljpeg
Im still getting hte exact same error after adding those... Any idea how to get rid of these undefined errors?

(Oh and i have the png and jpeg header included in the source...)

If you need to see the whole makefile, just tell me and ill post it.
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Are you using C++? Alot of libs headers need extern "C" {} added around the code to work in C++.

If not, post the exact error and the makefile.

Also bear in mind order is important. Countless times I've had to add libs twice just to get the order right.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Kojima wrote: Also bear in mind order is important. Countless times I've had to add libs twice just to get the order right.
That's most likely it. Permutate through the order of your links until it works.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

this order work fine for me

-lpng -lz -ljpeg -lm \
-lSDL_image -lSDL_mixer \
-lfreetype -lstdc++ -lsupc++ \
10011011 00101010 11010111 10001001 10111010
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

Just tried yours and nothing :(

All im getting is inside SDL_image's IMG_Load function, there are undefined references to jpeg and png calls/functions...
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Did you try the Extern "C" thing? That usually solves unresolved links when using C++ (you havn't stated which you use)
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

is your libraries of images installed
10011011 00101010 11010111 10001001 10111010
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

The only thing i havent tried is the extern C thing, but where should i put it? Around the including of SDL?
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

if you are coding in c++ then say you have main.cpp and
wanted to use a texure.c file made from bin2c

Code: Select all

extern "C" &#123;
//c stuff goes here
//ex. if you bin2c a image and your output is a tex_mario.c file
//the object is made into a .c file but you want to use in C++
//to use the image and store array into a buffer and so forth
//you would need to make file known to sources by 
//making that file extern to all sources ....and to do
//this you need to add its use in these braces 
extern unsigned int size_tex_mario;
extern unsigned char tex_mario&#91;&#93;;
&#125;; 
and thats one of the ways you can use extern "C"
the undefined errors have nothing to with extern "C" {
the undefined errors have nothing to do with if you include
in C or C++

this is a preproccessor problem ...so check your include
ordering ...tip: sdl_image.h uses png so include png.h earlier
so sdl_image.h can use ....if its not your preproccessor order
then either your linking yet again is wrong or the compiler is
not finding the libraries ....so double check by reconfiguring,
remaking, and then remake installing all the libs needed

if you do all this and yet you have the same problem then come back :P
10011011 00101010 11010111 10001001 10111010
Post Reply