Hi,
I am trying to make a custom build of libpng in my home directory, using a libz build that I made in my home directory also. Both are latest version, libpng 1.6.37 same as OpenBSD's port https://cvsweb.openbsd.org/ports/graphics/png/Makefile?rev=1.125&content-type=text/x-cvsweb-markup and libz the latest one they published. For zlib it's 1.2.11 from http://zlib.net/ from 2017, OpenBSD does not have a port but base bundles a 2009 version. Since 2009, significantly an export "inflateReset2" has been added. I'll start with the detail problem, and discuss the reproduction at the bottom: This has brought me to the bizarre issue that the libpng build plainly refuses to link to my custom libz file /home/myuser/lib/libz.so.1 . Instead, it insists with linking to the OS' global /usr/lib/libz.so.5.0 . /home/myuser/lib/ contains libz.so , libz.a, libz.so.1 and libz.so.1.2.11 . I have reduced the issue to the libpng build step where it produces libpng.so: /usr/local/bin/egcc -shared -fPIC -DPIC -o .libs/libpng.so.16.37 .libs/png.o .libs/pngerror.o .libs/pngget.o .libs/pngmem.o .libs/pngpread.o .libs/pngread.o .libs/pngrio.o .libs/pngrtran.o .libs/pngrutil.o .libs/pngset.o .libs/pngtrans.o .libs/pngwio.o .libs/pngwrite.o .libs/pngwtran.o .libs/pngwutil.o -L/home/myuser/lib -lm -lz -Og -g -fstack-protector-all [with or without: -Wl,--version-script=libpng.vers] [with or without: -Wl,-t] When provided with "-Wl,-t", LD run by GCC prints out: "/usr/lib/crtbeginS.o .libs/png.o .libs/pngerror.o .libs/pngget.o .libs/pngmem.o .libs/pngpread.o .libs/pngread.o .libs/pngrio.o .libs/pngrtran.o .libs/pngrutil.o .libs/pngset.o .libs/pngtrans.o .libs/pngwio.o .libs/pngwrite.o .libs/pngwtran.o .libs/pngwutil.o /usr/lib/libm.so.10.1 /usr/lib/libz.so.5.0 /usr/lib/crtendS.o" which shows that already at link time it picks the OS global one (that is /usr/lib/libz.so.5.0). What appears is that GCC ignores the "-L" search path given to it. "readelf -d .libs/libpng.so.16.37" shows: "Dynamic section at offset 0x40050 contains 25 entries: Tag Type Name/Value 0x000000000000001d (RUNPATH) Library runpath: [/home/myuser/lib] 0x0000000000000001 (NEEDED) Shared library: [libm.so.10.1] 0x0000000000000001 (NEEDED) Shared library: [libz.so.5.0]" Again providing receipt that the wrong LibZ is linked. "objdump -p .libs/libpng.so.16.37" shows the same: ".libs/libpng.so.16.37: file format elf64-x86-64 Program Header: ... Dynamic Section: RUNPATH /home/myuser/lib NEEDED libm.so.10.1 NEEDED libz.so.5.0" The way I got to this issue, was that the libpng "make" would crash with: "ld: error: undefined symbol: inflateReset2 >>> referenced by pngfix.c:2184 (contrib/tools/pngfix.c:2184) >>> contrib/tools/pngfix.o:(zlib_reset) collect2: error: ld returned 1 exit status" This turned out to be that the libpng build process' linking of its "pngfix" accessory tool, would crash because inflateReset2 was not found in the OS' libz (but it is in my custom one). "ldd" showed that libpng.so.17.37 already linked to the OS provided one as discussed above. Whole console interaction leading to the crash below. This whole experience makes me suspicious that maybe for instance "libz" is a reserved filename where only the OS' installation is accepted, but that would make no sense at all? Any thoughts for how to successfully make GCC link, please let me know, Thanks, Bob $ CC=/usr/local/bin/egcc \ > CXX=/usr/local/bin/eg++ \ > LD_LIBRARY_PATH=/home/myuser/lib \ > LDFLAGS="-L/home/myuser/lib -lz " \ > LIBS="-L/home/myuser/lib -I/home/myuser/include -lz " \ > CFLAGS="-Og -g -fstack-protector-all -fpic \ > -I/home/myuser/include -L/home/myuser/lib -lz" \ > CPPFLAGS="-Og -g -fstack-protector-all -fpic \ > -I/home/myuser/include -L/home/myuser/lib -lz " \ > ./configure \ > --prefix=/home/myuser \ > --enable-hardware-optimizations=no \ > --with-pic=yes \ > --enable-unversioned-links \ > --with-zlib-prefix=/home/myuser/lib checking whether build environment is sane... yes checking for a thread-safe mkdir -p... ./install-sh -c -d checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether to enable maintainer-specific portions of Makefiles... no checking for gcc... /usr/local/bin/egcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether /usr/local/bin/egcc accepts -g... yes checking for /usr/local/bin/egcc option to accept ISO C89... none needed checking whether /usr/local/bin/egcc understands -c and -o together... yes checking whether make supports the include directive... yes (GNU style) checking dependency style of /usr/local/bin/egcc... gcc3 checking dependency style of /usr/local/bin/egcc... gcc3 checking build system type... x86_64-unknown-openbsd6.7 checking host system type... x86_64-unknown-openbsd6.7 checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking how to print strings... print -r checking for ld used by /usr/local/bin/egcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking how to run the C preprocessor... /usr/local/bin/egcc -E checking for gawk... (cached) awk checking whether ln -s works... yes checking whether make sets $(MAKE)... (cached) yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking the maximum length of command line arguments... 393216 checking how to convert x86_64-unknown-openbsd6.7 file names to x86_64-unknown-openbsd6.7 format... func_convert_file_noop checking how to convert x86_64-unknown-openbsd6.7 file names to toolchain format... func_convert_file_noop checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$ checking for dlltool... no checking how to associate runtime and link libraries... print -r -- checking for ar... ar checking for archiver @FILE support... @ checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from /usr/local/bin/egcc object... ok checking for sysroot... no checking for a working dd... /bin/dd checking how to truncate binary pipes... /bin/dd bs=4096 count=1 checking for mt... mt checking if mt is a manifest tool... no checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if /usr/local/bin/egcc supports -fno-rtti -fno-exceptions... no checking for /usr/local/bin/egcc option to produce PIC... -fPIC -DPIC checking if /usr/local/bin/egcc PIC flag -fPIC -DPIC works... yes checking if /usr/local/bin/egcc static flag -static works... yes checking if /usr/local/bin/egcc supports -c -o file.o... yes checking if /usr/local/bin/egcc supports -c -o file.o... (cached) yes checking whether the /usr/local/bin/egcc linker (/usr/bin/ld) supports shared libraries... yes checking whether -lc should be explicitly linked in... yes checking dynamic linker characteristics... openbsd6.7 ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking that AWK works... ok checking if we need to force back C standard to C89... no checking for ANSI C header files... (cached) yes checking for an ANSI C-conforming const... yes checking for size_t... yes checking whether struct tm is in sys/time.h or time.h... time.h checking for C/C++ restrict keyword... __restrict checking for working strtod... yes checking for pow... no checking for pow in -lm... yes checking for clock_gettime... yes checking for zlibVersion in -lz... yes checking for feenableexcept in -lm... yes checking for feenableexcept... yes checking if using Solaris linker... no checking if libraries can be versioned... yes checking for symbol prefix... configure: pkgconfig directory is ${libdir}/pkgconfig configure: Extra options for compiler: checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating libpng.pc config.status: creating libpng-config config.status: creating config.h config.status: executing depfiles commands config.status: executing libtool commands $ gmake -j3 VERBOSE=1 rm -f pnglibconf.c pnglibconf.tf[45] awk -f ./scripts/options.awk out=pnglibconf.tf4 version=search\ ./pngconf.h ./scripts/pnglibconf.dfa\ ./pngusr.dfa 1>&2 awk -f ./scripts/options.awk out=pnglibconf.tf5 pnglibconf.tf4 1>&2 rm pnglibconf.tf4 mv pnglibconf.tf5 pnglibconf.c rm -f pnglibconf.out pnglibconf.tf[12] test -d scripts || mkdir scripts || test -d scripts /usr/local/bin/egcc -E -DHAVE_CONFIG_H -I. \ -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -DPNGLIB_LIBNAME='PNG16_0' -DPNGLIB_VERSION='1.6.37' -DSYMBOL_PREFIX='' -DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE pnglibconf.c > pnglibconf.tf1 awk -f "./scripts/dfn.awk" out="pnglibconf.tf2" pnglibconf.tf1 1>&2 rm -f pnglibconf.tf1 mv pnglibconf.tf2 pnglibconf.out rm -f pnglibconf.h cp pnglibconf.out pnglibconf.h gmake all-am gmake[1]: Entering directory '/home/myuser/src/libpng' :>pngprefix.h rm -f scripts/vers.out scripts/vers.tf[12] cp libpng-config libpng16-config test -d scripts || mkdir scripts || test -d scripts cp libpng.pc libpng16.pc /usr/local/bin/egcc -E -DHAVE_CONFIG_H -I. \ -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -DPNGLIB_LIBNAME='PNG16_0' -DPNGLIB_VERSION='1.6.37' -DSYMBOL_PREFIX='' -DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE scripts/vers.c > scripts/vers.tf1 depbase=`echo pngtest.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngtest.o -MD -MP -MF $depbase.Tpo -c -o pngtest.o pngtest.c &&\ mv -f $depbase.Tpo $depbase.Po depbase=`echo contrib/tools/pngcp.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT contrib/tools/pngcp.o -MD -MP -MF $depbase.Tpo -c -o contrib/tools/pngcp.o contrib/tools/pngcp.c &&\ mv -f $depbase.Tpo $depbase.Po awk -f "./scripts/dfn.awk" out="scripts/vers.tf2" scripts/vers.tf1 1>&2 rm -f scripts/vers.tf1 mv scripts/vers.tf2 scripts/vers.out depbase=`echo contrib/libtests/timepng.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT contrib/libtests/timepng.o -MD -MP -MF $depbase.Tpo -c -o contrib/libtests/timepng.o contrib/libtests/timepng.c &&\ mv -f $depbase.Tpo $depbase.Po depbase=`echo contrib/tools/pngfix.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT contrib/tools/pngfix.o -MD -MP -MF $depbase.Tpo -c -o contrib/tools/pngfix.o contrib/tools/pngfix.c &&\ mv -f $depbase.Tpo $depbase.Po depbase=`echo png.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT png.lo -MD -MP -MF $depbase.Tpo -c -o png.lo png.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT png.lo -MD -MP -MF .deps/png.Tpo -c png.c -fPIC -DPIC -o .libs/png.o depbase=`echo pngerror.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngerror.lo -MD -MP -MF $depbase.Tpo -c -o pngerror.lo pngerror.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngerror.lo -MD -MP -MF .deps/pngerror.Tpo -c pngerror.c -fPIC -DPIC -o .libs/pngerror.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngerror.lo -MD -MP -MF .deps/pngerror.Tpo -c pngerror.c -fPIC -DPIC -o pngerror.o >/dev/null 2>&1 depbase=`echo pngget.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngget.lo -MD -MP -MF $depbase.Tpo -c -o pngget.lo pngget.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngget.lo -MD -MP -MF .deps/pngget.Tpo -c pngget.c -fPIC -DPIC -o .libs/pngget.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT png.lo -MD -MP -MF .deps/png.Tpo -c png.c -fPIC -DPIC -o png.o >/dev/null 2>&1 depbase=`echo pngmem.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngmem.lo -MD -MP -MF $depbase.Tpo -c -o pngmem.lo pngmem.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngmem.lo -MD -MP -MF .deps/pngmem.Tpo -c pngmem.c -fPIC -DPIC -o .libs/pngmem.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngmem.lo -MD -MP -MF .deps/pngmem.Tpo -c pngmem.c -fPIC -DPIC -o pngmem.o >/dev/null 2>&1 libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngget.lo -MD -MP -MF .deps/pngget.Tpo -c pngget.c -fPIC -DPIC -o pngget.o >/dev/null 2>&1 depbase=`echo pngpread.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngpread.lo -MD -MP -MF $depbase.Tpo -c -o pngpread.lo pngpread.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngpread.lo -MD -MP -MF .deps/pngpread.Tpo -c pngpread.c -fPIC -DPIC -o .libs/pngpread.o depbase=`echo pngread.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngread.lo -MD -MP -MF $depbase.Tpo -c -o pngread.lo pngread.c &&\ mv -f $depbase.Tpo $depbase.Plo depbase=`echo pngrio.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrio.lo -MD -MP -MF $depbase.Tpo -c -o pngrio.lo pngrio.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngread.lo -MD -MP -MF .deps/pngread.Tpo -c pngread.c -fPIC -DPIC -o .libs/pngread.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngpread.lo -MD -MP -MF .deps/pngpread.Tpo -c pngpread.c -fPIC -DPIC -o pngpread.o >/dev/null 2>&1 libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrio.lo -MD -MP -MF .deps/pngrio.Tpo -c pngrio.c -fPIC -DPIC -o .libs/pngrio.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrio.lo -MD -MP -MF .deps/pngrio.Tpo -c pngrio.c -fPIC -DPIC -o pngrio.o >/dev/null 2>&1 depbase=`echo pngrtran.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrtran.lo -MD -MP -MF $depbase.Tpo -c -o pngrtran.lo pngrtran.c &&\ mv -f $depbase.Tpo $depbase.Plo depbase=`echo pngrutil.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrutil.lo -MD -MP -MF $depbase.Tpo -c -o pngrutil.lo pngrutil.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrtran.lo -MD -MP -MF .deps/pngrtran.Tpo -c pngrtran.c -fPIC -DPIC -o .libs/pngrtran.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrutil.lo -MD -MP -MF .deps/pngrutil.Tpo -c pngrutil.c -fPIC -DPIC -o .libs/pngrutil.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngread.lo -MD -MP -MF .deps/pngread.Tpo -c pngread.c -fPIC -DPIC -o pngread.o >/dev/null 2>&1 libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrutil.lo -MD -MP -MF .deps/pngrutil.Tpo -c pngrutil.c -fPIC -DPIC -o pngrutil.o >/dev/null 2>&1 libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngrtran.lo -MD -MP -MF .deps/pngrtran.Tpo -c pngrtran.c -fPIC -DPIC -o pngrtran.o >/dev/null 2>&1 depbase=`echo pngset.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngset.lo -MD -MP -MF $depbase.Tpo -c -o pngset.lo pngset.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngset.lo -MD -MP -MF .deps/pngset.Tpo -c pngset.c -fPIC -DPIC -o .libs/pngset.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngset.lo -MD -MP -MF .deps/pngset.Tpo -c pngset.c -fPIC -DPIC -o pngset.o >/dev/null 2>&1 depbase=`echo pngtrans.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngtrans.lo -MD -MP -MF $depbase.Tpo -c -o pngtrans.lo pngtrans.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngtrans.lo -MD -MP -MF .deps/pngtrans.Tpo -c pngtrans.c -fPIC -DPIC -o .libs/pngtrans.o depbase=`echo pngwio.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwio.lo -MD -MP -MF $depbase.Tpo -c -o pngwio.lo pngwio.c &&\ mv -f $depbase.Tpo $depbase.Plo depbase=`echo pngwrite.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwrite.lo -MD -MP -MF $depbase.Tpo -c -o pngwrite.lo pngwrite.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwio.lo -MD -MP -MF .deps/pngwio.Tpo -c pngwio.c -fPIC -DPIC -o .libs/pngwio.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwrite.lo -MD -MP -MF .deps/pngwrite.Tpo -c pngwrite.c -fPIC -DPIC -o .libs/pngwrite.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngtrans.lo -MD -MP -MF .deps/pngtrans.Tpo -c pngtrans.c -fPIC -DPIC -o pngtrans.o >/dev/null 2>&1 libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwio.lo -MD -MP -MF .deps/pngwio.Tpo -c pngwio.c -fPIC -DPIC -o pngwio.o >/dev/null 2>&1 depbase=`echo pngwtran.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwtran.lo -MD -MP -MF $depbase.Tpo -c -o pngwtran.lo pngwtran.c &&\ mv -f $depbase.Tpo $depbase.Plo depbase=`echo pngwutil.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/sh ./libtool --tag=CC --mode=compile /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwutil.lo -MD -MP -MF $depbase.Tpo -c -o pngwutil.lo pngwutil.c &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwtran.lo -MD -MP -MF .deps/pngwtran.Tpo -c pngwtran.c -fPIC -DPIC -o .libs/pngwtran.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwutil.lo -MD -MP -MF .deps/pngwutil.Tpo -c pngwutil.c -fPIC -DPIC -o .libs/pngwutil.o libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwrite.lo -MD -MP -MF .deps/pngwrite.Tpo -c pngwrite.c -fPIC -DPIC -o pngwrite.o >/dev/null 2>&1 libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwtran.lo -MD -MP -MF .deps/pngwtran.Tpo -c pngwtran.c -fPIC -DPIC -o pngwtran.o >/dev/null 2>&1 rm -f libpng.vers cp scripts/vers.out libpng.vers depbase=`echo contrib/tools/png-fix-itxt.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT contrib/tools/png-fix-itxt.o -MD -MP -MF $depbase.Tpo -c -o contrib/tools/png-fix-itxt.o contrib/tools/png-fix-itxt.c &&\ mv -f $depbase.Tpo $depbase.Po libtool: compile: /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT pngwutil.lo -MD -MP -MF .deps/pngwutil.Tpo -c pngwutil.c -fPIC -DPIC -o pngwutil.o >/dev/null 2>&1 depbase=`echo contrib/libtests/pngunknown.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT contrib/libtests/pngunknown.o -MD -MP -MF $depbase.Tpo -c -o contrib/libtests/pngunknown.o contrib/libtests/pngunknown.c &&\ mv -f $depbase.Tpo $depbase.Po depbase=`echo contrib/libtests/pngstest.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT contrib/libtests/pngstest.o -MD -MP -MF $depbase.Tpo -c -o contrib/libtests/pngstest.o contrib/libtests/pngstest.c &&\ mv -f $depbase.Tpo $depbase.Po depbase=`echo contrib/libtests/pngvalid.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT contrib/libtests/pngvalid.o -MD -MP -MF $depbase.Tpo -c -o contrib/libtests/pngvalid.o contrib/libtests/pngvalid.c &&\ mv -f $depbase.Tpo $depbase.Po depbase=`echo contrib/libtests/pngimage.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ /usr/local/bin/egcc -DHAVE_CONFIG_H -I. -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -MT contrib/libtests/pngimage.o -MD -MP -MF $depbase.Tpo -c -o contrib/libtests/pngimage.o contrib/libtests/pngimage.c &&\ mv -f $depbase.Tpo $depbase.Po /bin/sh ./libtool --tag=CC --mode=link /usr/local/bin/egcc -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -no-undefined -export-dynamic -version-number 16:37:0 -Wl,--version-script=libpng.vers -L/home/myuser/build/lib -lz -o libpng.la -rpath /home/myuser/build/lib png.lo pngerror.lo pngget.lo pngmem.lo pngpread.lo pngread.lo pngrio.lo pngrtran.lo pngrutil.lo pngset.lo pngtrans.lo pngwio.lo pngwrite.lo pngwtran.lo pngwutil.lo -lm -lz -lm -L/home/myuser/build/lib -I/home/myuser/build/include -lz /bin/sh ./libtool --tag=CC --mode=link /usr/local/bin/egcc -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -L/home/myuser/build/lib -lz -o png-fix-itxt contrib/tools/png-fix-itxt.o -lm -lz -lm -L/home/myuser/build/lib -I/home/myuser/build/include -lz libtool: link: /usr/local/bin/egcc -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -o png-fix-itxt contrib/tools/png-fix-itxt.o -I/home/myuser/build/include -L/home/myuser/build/lib -lm -lz libtool: link: /usr/local/bin/egcc -shared -fPIC -DPIC -o .libs/libpng.so.16.37 .libs/png.o .libs/pngerror.o .libs/pngget.o .libs/pngmem.o .libs/pngpread.o .libs/pngread.o .libs/pngrio.o .libs/pngrtran.o .libs/pngrutil.o .libs/pngset.o .libs/pngtrans.o .libs/pngwio.o .libs/pngwrite.o .libs/pngwtran.o .libs/pngwutil.o -L/home/myuser/build/lib -lm -lz -Og -g -fstack-protector-all -Wl,--version-script=libpng.vers libtool: link: ar cru .libs/libpng.a png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o libtool: link: ranlib .libs/libpng.a libtool: link: ( cd ".libs" && rm -f "libpng.la" && ln -s "../libpng.la" "libpng.la" ) cp libpng.la libpng16.la /bin/sh ./libtool --tag=CC --mode=link /usr/local/bin/egcc -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -L/home/myuser/build/lib -lz -o pngfix contrib/tools/pngfix.o libpng16.la -lm -lz -lm -L/home/myuser/build/lib -I/home/myuser/build/include -lz /bin/sh ./libtool --tag=CC --mode=link /usr/local/bin/egcc -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -L/home/myuser/build/lib -lz -L/home/myuser/build/lib -lz -o pngtest pngtest.o libpng16.la -lm -lz -lm -L/home/myuser/build/lib -I/home/myuser/build/include -lz libtool: link: /usr/local/bin/egcc -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -o .libs/pngtest pngtest.o -I/home/myuser/build/include -L/home/myuser/build/lib -L./.libs -lpng16 -lm -lz -Wl,-rpath,/home/myuser/build/lib libtool: link: /usr/local/bin/egcc -Og -g -fstack-protector-all -fpic -I/home/myuser/build/include -o .libs/pngfix contrib/tools/pngfix.o -I/home/myuser/build/include -L/home/myuser/build/lib -L./.libs -lpng16 -lm -lz -Wl,-rpath,/home/myuser/build/lib ld: error: undefined symbol: inflateReset2 >>> referenced by pngfix.c:2184 (contrib/tools/pngfix.c:2184) >>> contrib/tools/pngfix.o:(zlib_reset) collect2: error: ld returned 1 exit status gmake[1]: *** [Makefile:1038: pngfix] Error 1 gmake[1]: *** Waiting for unfinished jobs.... gmake[1]: Leaving directory '/home/myuser/src/libpng' gmake: *** [Makefile:820: all] Error 2 |
On 2021-02-23, Bob <[hidden email]> wrote:
> Hi, > > I am trying to make a custom build of libpng in my home directory, > using a libz build that I made in my home directory also. > > Both are latest version, libpng 1.6.37 same as OpenBSD's port > https://cvsweb.openbsd.org/ports/graphics/png/Makefile?rev=1.125&content-type=text/x-cvsweb-markup > and libz the latest one they published. For zlib it's 1.2.11 > from http://zlib.net/ from 2017, OpenBSD does not have a port but > base bundles a 2009 version. Since 2009, significantly an export > "inflateReset2" has been added. As you have seen it is difficult to have library functions in one version in base and in another version built elsewhere (whether that's in $HOME or in ports). Ports only does this for libraries where there's really no other choice and where that has been done they're used *very* rarely (the port can then not depend on any libraries which pull in the library from base). Currently that is libbind (used only by asdig and zeek) and openssl (used as a static library by sslscan, and dynamic for nrpe and nsca-ng). > I'll start with the detail problem, and discuss the reproduction at the > bottom: > > > This has brought me to the bizarre issue that the libpng build plainly > refuses to link to my custom libz file /home/myuser/lib/libz.so.1 . > Instead, it insists with linking to the OS' global > /usr/lib/libz.so.5.0 . This is as expected really, it looks for the higher library version number. > I have reduced the issue to the libpng build step where it produces > libpng.so: > > /usr/local/bin/egcc -shared -fPIC -DPIC -o .libs/libpng.so.16.37 > .libs/png.o .libs/pngerror.o .libs/pngget.o .libs/pngmem.o > .libs/pngpread.o .libs/pngread.o .libs/pngrio.o .libs/pngrtran.o > .libs/pngrutil.o .libs/pngset.o .libs/pngtrans.o .libs/pngwio.o > .libs/pngwrite.o .libs/pngwtran.o .libs/pngwutil.o -L/home/myuser/lib > -lm -lz -Og -g -fstack-protector-all > [with or without: -Wl,--version-script=libpng.vers] > [with or without: -Wl,-t] You might get somewhere further with something like "-nostdlib -L/home/myuser/lib -L/usr/lib". You might need either rpath or change to using static libs. (not relevant to libpng which is in C, but if you try to build C++ software with GCC rather than Clang you will often run into problems with incompatible standard libraries too). > What appears is that GCC ignores the "-L" search path given to it. -L adds, it doesn't overwrite. Hopefully you're just doing this to use pngfix; if you try and replace the installed libpng with one built like this you're likely to end up with all sorts of problems. |
On Wed, Feb 24, 2021 at 02:17:14PM -0000, Stuart Henderson wrote:
> On 2021-02-23, Bob <[hidden email]> wrote: > > Hi, > > > > I am trying to make a custom build of libpng in my home directory, > > using a libz build that I made in my home directory also. > > > > Both are latest version, libpng 1.6.37 same as OpenBSD's port > > https://cvsweb.openbsd.org/ports/graphics/png/Makefile?rev=1.125&content-type=text/x-cvsweb-markup > > and libz the latest one they published. For zlib it's 1.2.11 > > from http://zlib.net/ from 2017, OpenBSD does not have a port but > > base bundles a 2009 version. Since 2009, significantly an export > > "inflateReset2" has been added. > > As you have seen it is difficult to have library functions in one > version in base and in another version built elsewhere (whether that's > in $HOME or in ports). Ports only does this for libraries where there's > really no other choice and where that has been done they're used *very* > rarely (the port can then not depend on any libraries which pull in the > library from base). Currently that is libbind (used only by asdig and > zeek) and openssl (used as a static library by sslscan, and dynamic > for nrpe and nsca-ng). > > > I'll start with the detail problem, and discuss the reproduction at the > > bottom: > > > > > > This has brought me to the bizarre issue that the libpng build plainly > > refuses to link to my custom libz file /home/myuser/lib/libz.so.1 . > > Instead, it insists with linking to the OS' global > > /usr/lib/libz.so.5.0 . > > This is as expected really, it looks for the higher library version > number. Not really, it's more that you have to make sure to put your own directory before the system directory, which requires a bit more magic than just -L. (remember that linking will stop at the first directory with a satisfying library, and link with the highest version number found in there, which is fortunate for stuff like libtool!) |
Free forum by Nabble | Edit this page |