bug-libtool
[Top][All Lists]
Advanced

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

bug#11537: Libtool 2.4.2 fails to handle library interdependencies


From: Kristian Spangsege
Subject: bug#11537: Libtool 2.4.2 fails to handle library interdependencies
Date: Tue, 22 May 2012 01:33:24 +0200

Libtool 2.4.2 (Ubuntu 12.04) fails to handle library interdependencies
- in particular C++ library interdependencies.

The interdependency is specified on the command line, and is recorded
correctly by libtool, however, since there is no dependency from the
point of view of the binary library files, and since libtool no longer
adds all dependency libraries on the command line, compiling of the
final application fails.

I suppose the problem is that libtool has been changed to set
link_all_deplibs=no on my platform, but I'm not sure.

Here is an example that illustrates the problem:

### create test files:
cat >alpha.hpp <<EOI
void alpha();
EOI
cat >alpha.cpp <<EOI
#include "alpha.hpp"
void alpha() {}
EOI
cat >beta.hpp <<EOI
#include "alpha.hpp"
void beta1();
inline void beta2() { alpha(); }
EOI
cat >beta.cpp <<EOI
#include "beta.hpp"
void beta1() {}
EOI
cat >app.cpp <<EOI
#include "beta.hpp"
int main()
{
  beta2();
  return 0;
}
EOI

### build 'libalpha':
libtool --tag=CXX --mode=compile g++ -c alpha.cpp
libtool --tag=CXX --mode=link g++ alpha.lo -o libalpha.la -rpath /tmp

### build 'libbeta':
libtool --tag=CXX --mode=compile g++ -c beta.cpp
libtool --tag=CXX --mode=link g++ beta.lo libalpha.la -o libbeta.la
-rpath /tmp # Depends on 'libalpha'

### build app:
libtool --tag=CXX --mode=link g++ app.cpp libbeta.la -o app

### error:
# In function `beta2()':
# app.cpp: undefined reference to `alpha()'


Of couse, if you forget about C++, then this change is probably ok,
since all dependencies would be reflected in the binary library files.
This is certainly not the case for C++.

I belive that the Libtool manual says unambiguously that this is
supposed to work:

"In any event, libtool provides a simple mechanism for you to declare
inter-library dependencies: for every library libname that your own
library depends on, simply add a corresponding -lname option to the
link line when you create your library."

http://www.gnu.org/software/libtool/manual/libtool.html#Inter_002dlibrary-dependencies


Note also that this actually worked in Libtool 2.2.6b (Ubuntu 10.04).

Also see this diff excerpt on libtool.m4 between 2.2.6b and 2.4.2:

@@ -4249,10 +4655,39 @@
   openbsd*)
     with_gnu_ld=no
     ;;
+ linux* | k*bsd*-gnu | gnu*)
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ ;;
   esac



ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: libtool 2.4.2-1ubuntu1
ProcVersionSignature: Ubuntu 3.2.0-24.38-generic 3.2.16
Uname: Linux 3.2.0-24-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.0.1-0ubuntu7
Architecture: amd64
Date: Tue May 22 00:37:22 2012
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release amd64
(20120425)
ProcEnviron:
 LANGUAGE=en_US:en
 TERM=xterm
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: libtool
UpgradeStatus: No upgrade log present (probably fresh install)





reply via email to

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