I’m cross-compiling some C code for Windows 7 and linking to libpng12.dll found here. Unfortunately, the line below causes a crash (GDB says segmentation fault):
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
I’m not sure where to start to debug this–that function seems very straightforward and unrelated to the rest of the code. Top of the backtrace looks like this:
#0 0xabababab in ?? ()
#1 0x6cc556d1 in png_set_read_fn () from c:\...libpng12.dll
#2 0x6cc7a5d4 in png_libpng_ver () from c:\...libpng12.dll
#3 0x00000038 in ?? ()
#4 0x0028f928 in ?? ()
I guess #4 is png_create_read_struct(), since #5 is the function I call it from.
Solved (unfortunately by trial & error) but just in case anyone else experiences this issue, it’s caused by an incorrect version of zlib (in my case, too old). You can check for this quite easily at runtime: