LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   building libpng-1.6.37 fails with call to zlib, but zlib is installed (https://www.linuxquestions.org/questions/linux-software-2/building-libpng-1-6-37-fails-with-call-to-zlib-but-zlib-is-installed-4175708733/)

cpeognsoelds 02-28-2022 06:23 PM

building libpng-1.6.37 fails with call to zlib, but zlib is installed
 
The hardware environment I am working in is a QNAP NAS with x86_64 architecture.
The software is a headless, embedded, QNAP-designed Debian-based Gnu/Linux distro based on kernel 4.14.24.

The key constraint in this environment is that there is no package manager, and the dependencies etc needed to build and install programs must be installed by hand using the Entware system. Basically, a parallel environment is created in /opt/Entware.
I have installed

Please accept that this is the environment I have to work in to get the functionality I need on my NAS. it's just a lot more painful than in other distros.I have installed most of the standard functionality of a standard linux distro, including core-utils, pkg-config, cmake, gawk, gcc, glib2,ldconfig, libacl, and more.

My current issue is in building libpng-1.6.37, which is depended on by gdk-pixbuf-2.42.6.

libpng depends on zlib, which installed first time without complaint.

my libpng-1.6.37 build fails with
Code:

Built target png_static
[ 81%] Building C object CMakeFiles/pngtest.dir/pngtest.c.o
[ 83%] Linking C executable pngtest
/opt/bin/ld: libpng16.so.16.37.0: undefined reference to `inflateValidate'
collect2: error: ld returned 1 exit status

inflate/Validate is a zlib function, so I suspect that zlib can't be found. But I don't know why.

what is the process to debug errors like this?

Many thanks for your help.

aus9 02-28-2022 10:38 PM

Hi until you get a better reply as I am on Debian

Quote:

inflate/Validate is a zlib function
confirmed IMHO by
Code:

strings /usr/lib/x86_64-linux-gnu/libz.so |grep inflateValidate
inflateValidate

ignoring pathway for build for debian is prefix=/usr ....I assume you built "whatever you called your zlib" with prefix=/opt

2) I had a quick test and can report
Code:

tar xvf libpng-1.6.37.tar.gz
cd libpng-1.6.37
configure --prefix=/opt # no errors seen

# but
cat config.log | grep error
Configured with: ../src/configure -v --with-pkgversion='Debian 11.2.0-16' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs \
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only \
--program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib \
--without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu \
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object \
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release \
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 \
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic \
--enable-offload-targets=nvptx-none=/build/gcc-11-PrvGcK/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=\
/build/gcc-11-PrvGcK/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu \
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
conftest.c:11:10: fatal error: ac_nonexistent.h: No such file or directory
conftest.c:11:10: fatal error: ac_nonexistent.h: No such file or directory
conftest.c:60:21: error: expected expression before ')' token
collect2: error: ld returned 1 exit status
| /* Override any GCC internal prototype to avoid an error

the bottom bits, starting from gcc....can be ignored.

See mention of zlib? I have broken the configured with line with line breaks to reduce side scrolling

Code:

configure --help
reveals you can set the pathway ....
Code:

./configure --help | grep zlib
  --with-zlib-prefix    prefix that may have been used in installed zlib

do not forget that you can always add pathways for configure to search if needed.

3) Do you see any /opt pathway in your pc files?.....they should have them but mine is built to /usr
Code:

cat /usr/lib/x86_64-linux-gnu/pkgconfig/zlib.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
sharedlibdir=${libdir}
includedir=${prefix}/include

Name: zlib
Description: zlib compression library
Version: 1.2.11

Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}


cpeognsoelds 03-01-2022 05:35 PM

This is a pretty darn good answer!
First, the zlib library I installed is in opt/lib
When I added the --with-zlib-prefix flag to the configure
Code:

./configure --prefix=/opt  --with-zlib-prefix=/opt/lib
I got the same result when I built it:

Code:

[~/gdk_files/libpng-1.6.37] # make check
make  check-am
make[1]: Entering directory '/share/CACHEDEV1_DATA/jmarks/gdk_files/libpng-1.6.37'
/bin/sh ./libtool  --tag=CC  --mode=link gcc  -g -O2  -o pngfix contrib/tools/pngfix.o libpng16.la -lm -lz -lm
libtool: link: gcc -g -O2 -o .libs/pngfix contrib/tools/pngfix.o  ./.libs/libpng16.so -lz -lm -Wl,-rpath -Wl,/opt/lib
/opt/bin/ld: ./.libs/libpng16.so: undefined reference to `inflateValidate'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:1036: pngfix] Error 1
make[1]: Leaving directory '/share/CACHEDEV1_DATA/jmarks/gdk_files/libpng-1.6.37'
make: *** [Makefile:1999: check] Error 2

So, why can't it find zlib (if that's the problem)?

Code:

[~/gdk_files/libpng-1.6.37] # ldconfig -v | grep libz
ldconfig: /lib/libqudev.so.0 is not a symbolic link
        libz.so.1 -> libz.so.1.2.8

ldconfig: Cannot stat /usr/lib/libuLinux_ha.so: No such file or directory
ldconfig: Cannot stat /usr/lib/libsmbpw.so: No such file or directory
ldconfig: Cannot stat /usr/local/lib/libc-client.so: No such file or directory
        libz.so.1 -> libz.so.1.2.11

It looks like there are two entries for libz.so.1
The first entry reported is in /lib :
Code:

libz.so.1 -> libz.so.1.2.8
The second is in /opt/lib
Code:

libz.so.1 -> libz.so.1.2.11
The one in /lib must be part of the embedded QNAP OS (but I didn't know I had it). The one in opt/lib I installed just the other day.

Is having links to two libraries of the same name in different locations a problem?
And, if it is, how do I fix it?
I don't know which is more recent. Should I uninstall the one I just installed?

Fun and games...
Many thanks.

cpeognsoelds 03-01-2022 08:39 PM

Solved!
I found this

One poster had success by adding linker information to the configure:
Code:

./configure --prefix=/usr LDFLAGS="-L/usr/lib -lz"
In my case the directory was /opt/lib

Code:

./configure --prefix=/opt  LDFLAGS="-L/opt/lib -lz" CPPFLAGS=/opt/include


All times are GMT -5. The time now is 07:12 PM.