Linking with -lname key
Vict <[email protected]>
| Newsgroups | gmane.comp.gnu.libtool.general |
|---|---|
| Message-ID | <CAJR0nqzJ=P8B0acTKLPUV32Nep+i4hwk6zkvb5ZVAtRzAQyjdQ@mail.gmail.com> |
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, ...).