libpng16.so: undefined reference to `inflateValidate'

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.