Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

monkeyman23555

macrumors newbie
Original poster
Feb 16, 2008
12
0
Hi

Well I am starting to program my ray tracer in xcode and I need to use pngwriter: http://pngwriter.sourceforge.net/
for simple image output.

I managed to get libpng work fine, by adding to my project the png.h file and the libpng.dylib from x11 to my project.

When I add both pngwriter.h and pngwriter.cpp to my project it starts to throw errors about linking and symbols not being found.

"_png_write_info", referenced from:
pngwriter::close() in pngwriter.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

When I include png.h in my main file without pngwriter being compiled then it builds fine.

Does anyone know what is going on?
 

monkeyman23555

macrumors newbie
Original poster
Feb 16, 2008
12
0
Well when I do this:

#include "png.h"

int main( int argc, char* const argv[] )
{
png_color_16 mybackground;
}


In my main file, then it does not give me an error, just warning that I did not use mybackground obviously. When I however include "pngwriter.cpp" in my build it gives me 29 errors of symbols not found.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Probably because pngwriter.h doesn't include everything that is needed, but png.h does which is why it works. Generally with libraries like this you don't include a specific header, you include the main generic header, which appears to be png.h in this case.
 

monkeyman23555

macrumors newbie
Original poster
Feb 16, 2008
12
0
Well pngwriter.h/.cpp worked with me in netbeans...

For the errors that I get when I do include it are all about png:
"_png_get_rowbytes", referenced from:
pngwriter::read_png_image(__sFILE*, png_struct_def*, png_info_struct*, unsigned char***, unsigned long*, unsigned long*)in pngwriter.o
pngwriter::readfromfile(char*) in pngwriter.o
"_png_set_expand", referenced from:
pngwriter::readfromfile(char*) in pngwriter.o
pngwriter::readfromfile(char*) in pngwriter.o
"_png_write_end", referenced from:
pngwriter::close() in pngwriter.o
"_png_set_gAMA", referenced from:
pngwriter::close() in pngwriter.o

Those are 4 of the errors. pngwriter.h does include "png.h" however.

Thats why I think it does not get the library in of libpng...
EDIT: Pngwriter is based on libpng, its not the same project...
 

monkeyman23555

macrumors newbie
Original poster
Feb 16, 2008
12
0
Well I went looking in the pngwriter.cpp and searched for one of the errors in pngwriter::close().

Now the error is:
"_png_write_end", referenced from:
pngwriter::close() in pngwriter.o

but in the cpp "png_write_end" is called. How come it puts a "_" infront of the call???
 

monkeyman23555

macrumors newbie
Original poster
Feb 16, 2008
12
0
Sorry for posting twice up there...

In the project settings under linking I made the Mach-O type to relocatable object. When I go to the settings of the dylib it is also Mach-O type...

I am not sure why it solved my problem, but if someone could tell me I'd be grateful...

Anyways thanks for the help...

EDIT: Now I am having the problem, when I compile and try to run it, it says there is no executable in the build directory...
 

MrEeeeez

macrumors newbie
Apr 5, 2009
1
0
Monkeyman, did you ever solve this problem? I'm running into the exact same situation.
 

monkeyman23555

macrumors newbie
Original poster
Feb 16, 2008
12
0
No I never actually did find a solution to this problem, I ended up just using the built in library, Core Image...

but that makes it not cross platform which is not to my taste...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.