I'm just reporting. I faced an issue while tried to build libpng on Amazon Linux (Red Hat based). But I got following error:

libtool: link: gcc -g -O2 -o .libs/pngfix contrib/tools/pngfix.o  ./.libs/libpng16.so -lz -lm
./.libs/libpng16.so: undefined reference to `inflateValidate'
collect2: error: ld returned 1 exit status

I checked environment variables and they were set normally. nm tool displayed that inflateValidate was in zlib library exports. I hope my solution (see below) will help somebody and will save his time.


The solution was to add LDDFLAGS to ./configure:

./configure --prefix=/usr LDFLAGS="-L/usr/lib -lz"

This solved the issue.


Running, on Lubuntu 16-04 on a 64 bits box, my solution was to specify the path to the zlib library.

First, build the zlib library:

./configure \
make install
make clean

Then, build the libpng library by specifying the dependency with the --with-zlib-prefix option:

./configure \
  --prefix=/home/stephane/programs/install \
make install
make clean

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.