Libtool fails to handle library interdependencies
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libtool (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Libtool fails to handle 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()'
ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: libtool 2.4.2-1ubuntu1
ProcVersionSign
Uname: Linux 3.2.0-24-generic x86_64
NonfreeKernelMo
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)
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