Hi Stuart and Marc, Thank you very much for responding.
I have given some more days to debugging this issue and narrowed it down very much now. I'll changing name on this thread to "GCC only on OpenBSD adds -L/usr/lib as prefix, why" and follow up there. Bob On Wednesday, 24 February 2021 15:40, Marc Espie <[email protected]> wrote: > On Wed, Feb 24, 2021 at 02:17:14PM -0000, Stuart Henderson wrote: > > > On 2021-02-23, Bob [email protected] 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!)

