When building with libpng-1.5.2 build fails. It works with older version of libpng-1.2.44
Making all in src
make all-am
gcc -DHAVE_CONFIG_H -I. `libpng-config --I_opts` -Wall --pedantic -std=gnu99 -g -O2 -MT rwpng.o -MD -MP -MF .deps/rwpng.Tpo -c -o rwpng.o rwpng.c
rwpng.c: In function ‘rwpng_version_info’:
rwpng.c:53: error: ‘ZLIB_VERSION’ undeclared (first use in this function)
rwpng.c:53: error: (Each undeclared identifier is reported only once
rwpng.c:53: error: for each function it appears in.)
rwpng.c:53: error: ‘zlib_version’ undeclared (first use in this function)
rwpng.c: In function ‘rwpng_read_image’:
rwpng.c:135: warning: passing argument 3 of ‘png_get_IHDR’ from incompatible pointer type
rwpng.c:135: warning: passing argument 4 of ‘png_get_IHDR’ from incompatible pointer type
rwpng.c: In function ‘rwpng_write_image_init’:
rwpng.c:312: error: ‘Z_BEST_COMPRESSION’ undeclared (first use in this function)
make[2]: *** [rwpng.o] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1
From the libpng home page, version 1.5 "no longer internally includes the zlib.h header file, so applications that formerly depended on png.h to provide that will now need to include it explicitly."
Will fix so that it is included explicitly.
On my machine (gcc/glib 4.7.0 and libpng 1.5.10) I need to add the following to fix these compile issues:
In rwpng.c add zlib include above include of png.h:
#if defined(PNG_LIBPNG_VER_MINOR) && PNG_LIBPNG_VER_MINOR >= 5
# include <zlib.h>
#endif
Secondly, in file rwpng.h in struct _mainprog_info, replace these lines:
ulg width; /* read/write */
ulg height; /* read/write */
ulg rowbytes; /* read */
with these:
#if defined(PNG_LIBPNG_VER_MINOR) && PNG_LIBPNG_VER_MINOR >= 5
png_uint_32 width; /* read/write */
png_uint_32 height; /* read/write */
png_uint_32 rowbytes; /* read */
#else
ulg width; /* read/write */
ulg height; /* read/write */
ulg rowbytes; /* read */
#endif
Aside, probably is better to move png.h include in rwpng.h file and change to system include: #include <png.h>
Regards,
Ryan