[Top][All Lists]

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

Re: inter-library dependency

From: Bob Friesenhahn
Subject: Re: inter-library dependency
Date: Sun, 20 Jan 2013 12:17:05 -0600 (CST)
User-agent: Alpine 2.01 (GSO 1266 2009-07-14)

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 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/
/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/] 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 '' 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 Friesenhahn
GraphicsMagick Maintainer,

reply via email to

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