Problems compiling with libpng

Moderator
Posts: 508
Joined: 2002.09
Post: #1
I'm having trouble getting my app to compile with the Release configuration. When I compile in Debug, it compiles fine and it launches perfectly, but when I switch to Release I get the following error:

Code:
/usr/bin/ld: Undefined symbols:
_crc32
_inflateReset
_inflate
_inflateEnd
_inflateInit_
/Users/neon/Documents/Development/Projects/@ local/Toxic Waste/libpng.a(png.o) reference to undefined _crc32
/Users/neon/Documents/Development/Projects/@ local/Toxic Waste/libpng.a(png.o) reference to undefined _inflateReset
/Users/neon/Documents/Development/Projects/@ local/Toxic Waste/libpng.a(pngread.o) reference to undefined _inflate
/Users/neon/Documents/Development/Projects/@ local/Toxic Waste/libpng.a(pngread.o) reference to undefined _inflateEnd
/Users/neon/Documents/Development/Projects/@ local/Toxic Waste/libpng.a(pngread.o) reference to undefined _inflateInit_
/Users/neon/Documents/Development/Projects/@ local/Toxic Waste/libpng.a(pngrutil.o) reference to undefined _inflate
/Users/neon/Documents/Development/Projects/@ local/Toxic Waste/libpng.a(pngrutil.o) reference to undefined _inflateReset

All errors point to libpng. I first thought it was because I was building a UB, but when I compiled as ppc only it gave me the same errors.
libpng.a is a universal binary (used lipo to merge them).

This is very weird because I used to be able to build my app, as UB without any problems.

"When you dream, there are no rules..."
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #2
Looks like it can't find zlib.
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #3
But why doesn't it complain in Debug mode? perhaps a path that isn't set?

"When you dream, there are no rules..."
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
ZeroLink won't give you link errors, and seems to automatically resolve them sometimes.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #5
Did you keep ZeroLink enabled for Debug? If so, then it's likely it just never got to the point where it needed to use zlib, since it doesn't look for symbols until it needs them.

Edit: bah! beaten by seconds.
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #6
OneSadCookie Wrote:ZeroLink won't give you link errors, and seems to automatically resolve them sometimes.

I said it before and I'll say it again, this is all your fault Rasp

No seriously, could it be that your ThirdParty scripts didn't include zlib, or maybe the version I downloaded from libpng wasn't the correct one.

"When you dream, there are no rules..."
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
No; static libraries cannot link to other libraries. Your application must link to zlib if it uses zlib functions, which it does if it's statically linked to libpng.
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #8
OK I fixed it by adding libz.dylib

It works now. I'll post a download link to my game once it's more mature Smile

"When you dream, there are no rules..."
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #9
One question -- why doesn't OS X include a libpng.dylib in the first place? Or if it does, where is it?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
Because nothing uses libpng?

(Not true, actually, as of 10.4 -- ImageIO does appear to use libpng internally. Everything higher-level is a client of ImageIO or QuickTime, though, so no need for a public libpng)
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #11
Well I had figured that since OS X has had support for loading and saving PNGs since it came out, I figured Apple had done the right thing and used libpng, instead of rolling their own png decoder -- which, as far as I'm concerned, would be madness.

But I have to assume, then, that they statically link libpng into some deeper framework and don't export any of its symbols. Seems silly, to me. Anybody who wants to load a png with alpha without premultiplication has to build their own libpng.

I know, I know, premultiplication is good but sometimes you want your data the way it's written, without swizzling. I've experimented with using the coregraphics APIs to load images with alpha channels, and no matter what, you get premultiplied data. Apple offers constants ( kCGImageAlphaFirst , kCGImageAlphaLast ) which in principle would give you non-premultiplied data, but when you use them in creating a bitmap context, you get a null context. On the cocoa-dev list I was told that those mechanisms aren't implemented.

It seems silly that apple doesn't offer a way to get non-premultiplied transparent images using ImageIO, and the old QuickDraw mechanisms, which worked, are deprecated. I have no idea if quicktime will do it...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  SDL, libpng, etc. on Intel misteranderson 6 4,984 Apr 27, 2006 12:52 PM
Last Post: misteranderson
  Problems with compiling code vbuser1338 3 3,557 Oct 28, 2005 02:48 PM
Last Post: vbuser1338