Issues linking with PNG Library externally


#1

Hi Jules,
We use FreeImage library in our project. As FreeImage has PNG lIbrary, we linked that library to JUCE instead of including the source. But there is a MACRO PNG_SETJMP_NOT_SUPPORTED which is not defined by FreeImage but defined by JUCE. And FreeImage uses some functions which is declared by that MACRO. If we link to that library without that MACRO , JUCE is not writing to file.

png_set_write_fn (); is failing. So we are setting the stream pointer explicitly after the png_set_write_fn (); is called to make it work temporarily.

Can you tell what is that MACRO for and how to resolve this issue without using that MACRO.

Thanks,
Noorul


#2

The macro just tell pnglib to set up its old C-style setjmp handling. I can’t really see why it’d fail, but looking again at the place where juce includes the external png headers, I’m not sure why I defined it. Maybe juce_PNGLoader.cpp line 84, would make more sense like this:

#else extern "C" { #include <png.h> #include <pngconf.h> } #endif


#3

So can i keep my fix by setting the O/P Stream explicitly after the png_set_write_fn ();


#4

I don’t understand what you mean about setting the output stream? And in what way is png_set_write_fn failing?


#5
The above function is called to set the [b]out[/b] stream. 
But [b]pngWriteStruct->io_ptr[/b] is NULL after the png_set_write_fn() call.
So i explicitly set the O/P stream like this 
[code] pngWriteStruct->io_ptr = &out; [/code]

The above function is called to set the out stream.
But pngWriteStruct->io_ptr is NULL after the png_set_write_fn() call.
So i explicitly set the O/P stream like this


#6

I really don’t know. I’m no expert on libpng, I can only really help with the version that’s built into juce - if you’re linking to some other version, then you’ll need to debug that yourself.


#7

Ok. Thanks, we are using the latest version of LibPNG.