[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

transitive shared library dependencies and installation

From: wferi
Subject: transitive shared library dependencies and installation
Date: Wed, 01 Jan 2020 20:38:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)


I'm experimenting with the attached skeleton project on a Debian buster
system (autoconf 2.69-11, automake 1:1.16.1-4 and libtool 2.4.6-9):

$ autoreconf -f -i
$ ./configure --prefix=/tmp/translib
$ make
$ ./translib; echo $?
$ make install
make[1]: Entering directory '/home/wferi/ha/pacemaker/translib'
 /bin/mkdir -p '/tmp/translib/lib'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   a/ b/ 
libtool: warning: relinking 'a/'
libtool: install: (cd /home/wferi/ha/pacemaker/translib; /bin/bash 
"/home/wferi/ha/pacemaker/translib/libtool"  --tag CC --mode=relink gcc -g -O2 
-avoid-version -o a/ -rpath /tmp/translib/lib a/a.lo b/ )
libtool: relink: gcc -shared  -fPIC -DPIC  a/.libs/a.o   -Wl,-rpath 
-Wl,/tmp/translib/lib -L/tmp/translib/lib -lb  -g -O2   -Wl,-soname -Wl, 
-o a/.libs/
/usr/bin/ld: cannot find -lb
collect2: error: ld returned 1 exit status
libtool:   error: error: relink 'a/' with the above command before 
installing it
make[1]: *** [Makefile:446: install-libLTLIBRARIES] Error 1
make[1]: Leaving directory '/home/wferi/ha/pacemaker/translib'
make: *** [Makefile:798: install-am] Error 2

No cyclic dependencies here, so this can be worked around by

-lib_LTLIBRARIES = a/ b/
+lib_LTLIBRARIES = b/ a/

in this case; is this expected (and documented) behavior?

Anyway: if, after a successful installation, I introduce a new symbol
(b2) in libb

diff --git a/a/a.c b/a/a.c
index ffc6553..8edd6f5 100644
--- a/a/a.c
+++ b/a/a.c
@@ -3,5 +3,5 @@
 int a (int x)
-    return b(x)+1;
+    return b(x)+b2(x)+1;
diff --git a/b/b.c b/b/b.c
index 27bd35f..a723efc 100644
--- a/b/b.c
+++ b/b/b.c
@@ -4,3 +4,8 @@ int b (int x)
     return x+2;
+int b2 (int x)
+    return x+3;
diff --git a/b/b.h b/b/b.h
index 2290498..c0ea0fb 100644
--- a/b/b.h
+++ b/b/b.h
@@ -1 +1,2 @@
 int b (int x);
+int b2 (int x);

and use it from liba, linking the final binary fails:

$ make
/bin/bash ./libtool  --tag=CC   --mode=link gcc  -g -O2 -avoid-version  -o 
translib translib.o a/ 
libtool: link: gcc -g -O2 -o .libs/translib translib.o  a/.libs/ 
-Wl,-rpath -Wl,/tmp/translib/lib
/usr/bin/ld: a/.libs/ undefined reference to `b2'

As I understand it, the -rpath linker option on the above command makes
a/.libs/ use the already installed (old) version of libb, which
lacks the b2 symbol.  What's the solution here?  Why isn't that -rpath
option "delayed" until the relinking phase?

Attachment: translib.tgz
Description: application/gtar-compressed

reply via email to

[Prev in Thread] Current Thread [Next in Thread]