Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Dec 2018 03:22:34 +0100
From:      Polytropon <freebsd@edvax.de>
To:        freebsd@dreamchaser.org
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: -lfoo vs /usr/local/lib/libfoo.so
Message-ID:  <20181208032234.47a2773d.freebsd@edvax.de>
In-Reply-To: <4e4f02e8-18b5-4e3e-2887-922946498bf1@dreamchaser.org>
References:  <4e4f02e8-18b5-4e3e-2887-922946498bf1@dreamchaser.org>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Fri, 7 Dec 2018 11:43:29 -0700, Gary Aitken wrote:
> In trying to build a dev version of a port, the cmake script includes
> many libraries explicitly, and one (-lhdf5-18) using -l:
> 
> /usr/bin/c++ -fPIC -Wall -Wextra -Wno-write-strings -O2 -pipe
>   -I/usr/local/include/hdf5-18 -fstack-protector -isystem /usr/local/include
>   -fno-strict-aliasing  -isystem /usr/local/include -std=c++11
>   -Wno-undefined-var-template -D_OCC64 -O2 -pipe -I/usr/local/include/hdf5-18
>   -fstack-protector -isystem /usr/local/include -fno-strict-aliasing  -isystem
>   /usr/local/include -Wl,--no-undefined -shared
>   -Wl,-soname,libFreeCADBase.so -o ../../lib/libFreeCADBase.so
> ... a bunch of .o files ...
>   -Wl,-rpath,/usr/local/lib:/usr/local/lib/qt4: -lhdf5-18
>   /usr/local/lib/libpython2.7.so
> ... <more .so files> ...
>   -lpthread -lz /usr/local/lib/qt4/libQtCore.so
> 
> The above command fails with
>    "/usr/bin/ld: cannot find -lhdf5-18"
> although
>    /usr/local/lib/libhdf5-18.so
> exists and the rpath flag indicates /usr/local/lib
> 
> If I replace -lhdf5-18 with /usr/local/lib/libhdf5-18.so it works.
> Curiously (to me) -lpthread and -lz are apparently working correctly,
> or at least aren't being mis-interpreted.
> 
> I've tried tweaking the command to use -Wl,-lhdf5-18 but that fails also.
> Can anyone explain to me what's going on?

Judging from the command presented, there is no (re)definition
of the library path, i. e., no -L parameter. This imples the
defaults are used. If I remember correctly, the system's library
path is always selected, so -lz -> /usr/lib/libz.so, as well as
-lpthread -> /usr/lib/libpthread.so will work for that reason.
As /usr/local/lib/libhdf5-18.so is in /usr/local/lib, this path
should either be part of the configuration (LDFLAGS) or named
explicitely as -L/usr/local/lib/libhdf5-18.so, similarly to the
-I/usr/local/include/hdf5-18 which is the directory expected to
contain the header files for the library in question.

So check the Makefile, maybe defaults it incorporates (or fails
to override or to extend), as well as - at least for testing -
using -L.

Reason simplified: The library referenced as "hdf5-18" (which
refers to libhdf5-18.so) cannot be found in any of the defined
library paths. This at least explains what you're seeing. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20181208032234.47a2773d.freebsd>