Loading pngs

How do you guys load pngs on os x? Whenever I tried using libpng in the past, xcode would never statically link the libpng.a file, it only worked if I already had the dylib installed, which is obviously not what I desired.

Xcode will prefer to link against a dynamic library if it can find one with the same name as the static library you're trying to link. You'll never want to install any library you're compiling against if you can possibly help it; put the compiled static lib somewhere in your project directory and reference it directly as a file in other linker flags.

ThemsAllTook Wrote:Xcode will prefer to link against a dynamic library if it can find one with the same name as the static library you're trying to link. You'll never want to install any library you're compiling against if you can possibly help it; put the compiled static lib somewhere in your project directory and reference it directly as a file in other linker flags.

I understand the thing about not having the dylib installed, which is why I currently do not. How would I directly reference it using linker flags though?

I went into build settings->Linking-> Other Linker Flags and entered exactly:

/Users/myComputer/Desktop/libpng.a for OTHER_LDFLAGS

libpng.a is located on my desktop.

And when I try to run the program I get this message:

i686-apple-darwin9-gcc-4.0.1: No such file or directory

I also tried creating a flag called OTHER_LDFLAGS and set it to the path and it didn't work either.

I also tried adding the path to "Library Search Paths" from the "Search Paths" group of build settings, and got a bunch of unknown symbol messsages. I also checked "Link Binary With Libraries" under target, to make sure that libpng.a was there and it was.

....into the terminal? What does it do? And I don't understand what you mean about changing the url. Is the end result suppose to be that I end up with a libpng.a file(already have one)?

This is all terribly confusing to me and I don't really understand any of it, is there not a simpler method for using pngs? Why is it so easy to load pngs on then iphone and such a nightmare to do it on a mac?

For something that works on both iPhone and Mac to load a PNG, you can do something like this (I just kind of threw it together real quick, so it's pseudocode-ish, but you should be able to figure it out from here):