[Top][All Lists]

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

Problems with libtool convenience libraries and automake

From: Kent Boortz
Subject: Problems with libtool convenience libraries and automake
Date: Mon, 09 Apr 2007 18:55:18 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.2 (darwin)


I build using "-static" given to libtool when creating executables, to
link statically with our own libraries, but dynamically against system
libraries. Works nicely, except one small problem.

One library, lets call it "libstat", I always want to compile static and
install in the more private "pkglib" directory. But it is also to be
used in the build itself as a libtool convenience library, when
creating other shared libraries and executables.

Problem is, I also want to create another shared library "libdyn" that
use objects in "libstat". I have included a small test setup below.

What happens is that the executable gets a dependency on
"", something I don't want and that I thought "-static"
when linking the executable took care of. If I change from
'pkglib_LTLIBRARIES' to 'noinst_LTLIBRARIES' in
"libstatdir/" the dependency goes away, but I do want to
install the library, at least the static version of it.

So I go use "libstat_la_LDFLAGS = -static" but this has the effect of
just producing a non position independent static library, i.e. no
libtool convenience library is created (even if placed in ".libs").
And when linking the "libdyn" library, the linker on AMD64 will

  gcc -shared  .libs/libdyn.o  ../libstatdir/.libs/libstat.a  -Wl,-soname 
-Wl, -o .libs/
  /usr/bin/ld: ../libstatdir/.libs/libstat.a(libstat.o): relocation R_X86_64_32 
against \
  `a local symbol' can not be used when making a shared object; recompile with 

So how do I make all these happen?

  - The executable to link statically against the objects from

  - The shared library "libdyn" link against the libtool convenience
    library in such a way it has no "" dependency, but
    includes the objects from "libstat" (position independent of

  - The static library "libstat.a" is installed when "make install",
    but not a shared version.

Or to put the question differently, when using a convenience library,
can I control if the static or shared library is installed? And if
static or shared linking is used when referenced from other parts of
the build, both references from building executables and other

I'm using

  libtool  1.5.22
  automake 1.9.6
  autoconf 2.60

I highly appreciate any help or pointers,


==== DO ====

libtoolize --automake --force --copy
automake --add-missing --force --copy
./configure ; make clean ; make
for f in `find exedir -name exebin`; do
  echo "**** Running ldd on $f"
  ldd $f
for f in `find lib*dir -name "lib*.so"`; do
  echo "**** Running ldd on $f"
  ldd $f
for f in `find lib*dir -name "lib*.a"`; do
  echo "**** Found $f"

==== ====

AC_INIT([exeproj], [1.0], address@hidden)
AC_CONFIG_FILES([Makefile exedir/Makefile
 libstatdir/Makefile  libdyndir/Makefile])

==== ====

SUBDIRS = libstatdir libdyndir exedir

==== exedir/ ====

bin_PROGRAMS   = exebin
exebin_SOURCES = exefile.c
exebin_LDADD   = $(top_builddir)/libstatdir/
exebin_LADD    = -static

==== libstatdir/ ====

# If line below replaces first line, deps are right, but no install
libstat_la_SOURCES = libstat.c
# First and second try was without this line below
libstat_la_LDFLAGS = -static

==== libdyndir/ ====

libdyn_la_SOURCES  = libdyn.c
libdyn_la_LIBADD   = $(top_builddir)/libstatdir/

==== exedir/exefile.c ====

extern int libstatfunc(void);

int main()
  return libstatfunc();

==== libstatdir/libstat.c ====

int libstatfunc(void)
  return 42;

==== libdyndir/libdyn.c ====

extern int libstatfunc(void);

int libdynfunc(void)
  return libstatfunc();

Kent Boortz, Senior Software Developer
Office: +46 18 174400 ext. 4450 (VoIP)
Office: +46 19 182931
Mobile: +46 70 2791171

reply via email to

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