Re: Linking with -lname key

2020-06-07 Thread Bob Friesenhahn

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
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt

Linking with -lname key

2020-06-07 Thread Vict
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?
$ ls /usr/local/lib
 libmy.a  libmy.la  libmy.so  libmy.so.0  libmy.so.0.0.0
libmy specifically made it dependent on libfltk and libEGL.
$ readelf -a /usr/local/lib/libmy.so | grep NEEDED
 (NEEDED) Shared library: [libfltk_SHARED.so.1.4]
 (NEEDED) Shared library: [libEGL.so.1]
 ...

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, ...).