Re: Linking with -lname key

Bob Friesenhahn <[email protected]>
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
On Sun, 7 Jun 2020, Vict wrote:

> Hello. Sorry if I didn't study the documentation well, but I don't understand
> the following aspect: why does libtool not link to its own la archives when
> linking with a -lname key?

Since you mention /usr/local/lib, can you confirm that LDFLAGS 
includes -L/usr/local/lib or that this argument was otherwise supplied 
to libtool?

> Let's link a test program with libmy:
> $ libtool --tag=CXX --mode=link g++ -o test_app  test_app.o -lmy
> test_app does not become dependent on libflt and libEGL (they are not in the
> dynamic section labeled "NEEDED".
> Linking test_app with absolute path to libmy does:
> $ libtool --tag=CXX --mode=link g++ -o test_app  test_app.o
>    /usr/local/lib/libmy.la
>
> but relying on absolute path is bad. I can’t know in advance
> where the library will be installed (/usr/lib, /usr/local/lib, ...).

By "know in advance", do you mean that as a software developer you 
can't know the configuration of some other system while building, or 
do you mean that the libraries may be installed to some random 
locations?

Note that when libtool is used to install libraries, it may re-link 
the libraries so that the results are different than with 
"--mode=link".

You should also consider that the operating system may or may not 
search the directory containing the shared libraries.  If it does not 
search the directory (e.g. /usr/local/lib in your case) and there is 
no run search path in the dependent library, then the dependent 
program won't run.

You should confirm if the libtool you are using is as delivered from 
the FSF release, or if it is a modified version.  Modified versions 
which change how library dependencies are treated abound.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.