Problem with the libpng....

Shogun
Unregistered
 
Post: #1
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
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
Quote this message in a reply
Shogun
Unregistered
 
Post: #3
This works, how ever I wounder if I want to link it statically shouldn't I do so with the libz as well?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
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
Quote this message in a reply
Shogun
Unregistered
 
Post: #5
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  libPng And Memory Access Violations Jaden 12 12,749 Sep 4, 2013 04:50 AM
Last Post: miye
  libpng loading junk at bottom of my OpenGL textures...? BinarySpike 6 6,311 Apr 19, 2007 12:20 PM
Last Post: BinarySpike
  libpng transparency problem wyrmmage 3 5,494 Mar 1, 2007 05:53 PM
Last Post: OneSadCookie
  Trouble writing PNGs with 16 bits per channel using libpng flash 2 3,945 Aug 28, 2006 11:01 AM
Last Post: flash
  libpng with OpenGL : return what? Jones 3 4,264 May 28, 2006 07:32 AM
Last Post: Jones