On Wed, 9 Jan 2013, Peter Johansson wrote:
Hello libtoolers,
I have a question how inter-library dependency is normally handled when
creating libraries (with libtool).
We use libtool to create a library yat. This library depends on several other
libraries: libbam, libz, libgsl, libgslcblas, and libm. We check for these
libraries with AC_SEARCH_LIBS in configure.ac with the result that LIBS get
populated with names of these libraries.
That has worked fine for long time until now when trying to build on a system
that only had libbam installed as a static library. Then I get this error
message
make[1]: Entering directory `/home/peterJo/projects/osd/_yat'
CXXLD yat/libyat.la
/usr/bin/ld: /home/peterJo/local/lib/libbam.a(bam.o): relocation R_X86_64_32
against `.rodata.str1.1' can not be used when making a shared object;
recompile with -fPIC
/home/peterJo/local/lib/libbam.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [yat/libyat.la] Error 1
I'm clearly doing something wrong here, and wonder what common practice is.
Should I make LIBS empty, but if I do that, variable 'dependency_libs' in
'libyat.la' also becomes empty?
If the static library (libbam) was built and installed by libtool,
then there should be an associated .la file which specifies libraries
that it depends on. Libtool searches for these .la files and applies
the dependency list from each matching .la file found. Most GNU/Linux
distributions have a habit of deleting .la files and this causes the
automatic dependencies support to fail. Configure scripts don't
use/depend on libtool .la files and use the exhastive (and
problematic) AC_SEARCH_LIBS approach instead. The linkage solution
found by configure might not in fact be correct.
As a further limitation, one can not normally build a shared library
by linking with a static library. If the static library was compiled
with -fPIC (unusual) then its code would be suitable for linkage into
a shared library (still not recommended because of potential symbol
conflicts). The linker is telling you that the static library used
was not compiled with -fPIC.
The simplest solution is to always build with shared libraries.
Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
_______________________________________________
https://lists.gnu.org/mailman/listinfo/libtool