Question

My platform:

Centos 6.X, Matplotlib-1.3.1, Numpy-1.8.0, Scipy 0.14.0.dev-bb608ba

I am trying to install libpng-1.6.6 to show .png files but when trying to make it is failing giving the below error.

NOTE: I have successfully pre-installed zlib (as well as freetype2) which is supposedly the error is pointing at.

pngfix.o: In function `zlib_reset':
/usr/lib/hue/libpng-1.6.6/contrib/tools/pngfix.c:2151: undefined reference to `inflateReset2'
collect2: ld returned 1 exit status
make[1]: *** [pngfix] Error 1
make[1]: Leaving directory `/usr/lib/hue/libpng-1.6.6'
make: *** [all] Error 2

Please see the link to my original thread matplotlib-pyplot-does-not-show-output-no-error

I checked the 2151 line of pngfix.c. It is the zlib_reset function and has something to do with the rc settings. Is it pointing to change some matplotlibrc settings?

   2136 zlib_reset(struct zlib *zlib, int window_bits)
   2137    /* Reinitializes a zlib with a different window_bits */
   2138 {
   2139    assert(zlib->state >= 0); /* initialized by zlib_init */
   2140
   2141    zlib->z.next_in = Z_NULL;
   2142    zlib->z.avail_in = 0;
   2143    zlib->z.next_out = Z_NULL;
   2144    zlib->z.avail_out = 0;
   2145
   2146    zlib->window_bits = window_bits;
   2147    zlib->compressed_digits = 0;
   2148    zlib->uncompressed_digits = 0;
   2149
   2150    zlib->state = 0; /* initialized, once */
   2151    zlib->rc = inflateReset2(&zlib->z, 0);
   2152    if (zlib->rc != Z_OK)
   2153    {
   2154       zlib_message(zlib, 1/*unexpected*/);
   2155       return 0;
   2156    }
   2157
   2158    return 1;
   2159 }
Was it helpful?

Solution

The problem with libpng install is solved.

The reason for the failure apparently appears to be version incompatibility, partly may be due to libpng-1.6.6 being unstable and has conflict with the zlib-1.2.8 being previously installed.

I uninstalled zlib-1.2.8 and reinstalled the older but stable release zlib-1.2.7 and instead of libpng-1.6.6, downloaded and installed libpng-1.5.9 and libpng installation passed the test successfully!

There was no zlib_reset - 'inflateReset2' problem this time. Don't know if there was a better solution, but I seemed to have bypassed the problem anyway. So the ideal compatible versions are zlib-1.2.7/libpng-1.5.9 instead of zlib-1.2.8/libpng-1.6.6 which I had been trying! Hope this helps.

OTHER TIPS

I had the same problem ("undefined reference to `inflateReset2'"), and tried libpng-1.6.6 and libpng-1.6.13 in combination with both zlib-1.2.8 and zlib-1.2.7. Nothing worked!

Then I came across this helpful post: https://stackoverflow.com/a/21345713

What happens is that libpng uses libtools for compiling and linking, and libtools by default only looks for libraries and headers in /usr/lib and /usr/include. So if you've installed a newer version of zlib manually in a local directory, libtools doesn't find it while trying to build libpng, and the error results from the requirement of libpng for a newer version of zlib.

The solution is to simply run ./configure with LDFLAGS and CPPFLAGS set to the lib and include directory where the newer version of zlib was installed. In my case:

LDFLAGS=-L$HOME/.local/lib CPPFLAGS=-I$HOME/.local/include ./configure --prefix=$HOME/.local

Hope this helps!

I would argue Flo's is best. Worked for me on centos 6.5.

More specifically:

sudo LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top