iDevGames Forums
Problem with the libpng.... - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Problem with the libpng.... (/thread-6005.html)



Problem with the libpng.... - Shogun - Dec 31, 2004 07:48 PM

Hi everyone, I'm using the terminal to compile my sdl (using the stuff from X11) programs written in C++. I'm using the sdl-config script to compile the programs and today I decided it was a good idea to try to use a png instead of a bmp since I like the idea of having transparant parts of an image. So I looked into the sdl docummentation and found the SDL_image library, however when I tried to compile it with:

Code:
g++ `sdl-config --libs` Image.cpp Blit.cpp Wait.cpp Main.cpp Load.cpp /sw/lib/libSDL_image.a  -I/sw/include -o Awesome -Wall

But this gave me a number of undefined symbols

Code:
etc...

_jpeg_start_decompress
_jpeg_std_error
_png_create_info_struct
_png_create_read_struct

etc...

Here I included the libpng and libjpeg librarys, and everything works fine untill I tried to statically link it with:

Code:
g++ `sdl-config --libs` Image.cpp Blit.cpp Wait.cpp Main.cpp Load.cpp /sw/lib/libSDL_image.a /sw/lib/libpng.a /sw/lib/libjpeg.a  -I/sw/include -o Awesome -Wall

This however gave me the error:

Code:
ld: /sw/lib/libpng.a(png.o) illegal reference to symbol: _crc32 defined in indirectly referenced dynamic library /usr/lib/libz.1.dylib

Then I tried to use the libpng-config script the same way as I use the sdl-config one (since I couldn't find any matrial on how you use it)

Code:
g++ `sdl-config --static-libs` `libpng-config --static-libs`  Image.cpp Blit.cpp Wait.cpp Main.cpp Load.cpp /sw/lib/libSDL_image.a /sw/lib/libjpeg.a -I/sw/include -o Awesome -Wall

But this gave me:

Code:
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

After this I pretty much ran out of ideas. So I'm wondering how you're supposed to do this probably?

Oh and I'm sorry for making such a long post, I'm used to post at a forum where you have to say exactly what you've tried and what you use to compile.


Problem with the libpng.... - OneSadCookie - Dec 31, 2004 11:26 PM

Don't apologize, it's nice to see a post for once where there's enough information provided to help -- too often it's "I can't compile SDL programs help" Smile

anyway, rather than trying to use the libpng config script, just add

Code:
-lz

to your link line. That should fix things Smile


Problem with the libpng.... - Shogun - Jan 1, 2005 06:19 AM

This works, how ever I wounder if I want to link it statically shouldn't I do so with the libz as well?


Problem with the libpng.... - OneSadCookie - Jan 1, 2005 10:58 AM

You can if you want, but I don't know why you'd want...

If you want to do that, you'll need to download the libz source, build it yourself, then rebuild libpng making sure that it links against your new static libz rather than the system's dynamic libz. Probably you'll have to edit the Makefile to accomplish that.

Also, watch out for the LGPL, statically linking SDL. You seem pretty clued up, so probably you've already realized the consequences of that, but I thought I should point it out Smile


Problem with the libpng.... - Shogun - Jan 1, 2005 01:01 PM

yeah, ok, thanks for your help, I think I'll stick with the dynamical one, a bit to much work the other way around I'm afraid.