automake
[Top][All Lists]
Advanced

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

Re: Building a static library consisting of libraries


From: Norbert Sendetzky
Subject: Re: Building a static library consisting of libraries
Date: Mon, 12 Jun 2006 20:59:07 +0200
User-agent: KMail/1.9.1

On Monday 12 June 2006 12:57, Ralf Wildenhues wrote:
> Mixing Libtool and non-Libtool libraries isn't the best idea.  Better to
> mix libtool libraries
>   lib_LTLIBRARIES = libfoo.la
>
> and libtool static libraries
>   lib_LTLIBRARIES = libbar.la
>   libbar_la_LDFLAGS = -static
>
> and libtool convenience archives
>   noinst_LTLIBRARIES = libbaz.la

Let me first ask a question: Are .a libraries (libopendbx.a) static libraries 
or is that only dependent on the -static flag? I ask because my understanding 
may be wrong, which depends on automake creating .a files if --enable-static 
is used.

> Yes.  Convenience archives get incorporated into other libraries.
> Static and shared libraries get dependency information.  Both the
> Automake and the Libtool manual have much more information.
>
> If with this information you still get errors, then please show
> what's going wrong in more detail (link command lines plus output,
> and/or Makefile.am snippets; cut and paste is much more helpful
> than describing errors; of course a reproducible example is best).

My Makefile.am in lib:

include_HEADERS = odbx.h

lib_LTLIBRARIES = libopendbx.la
libopendbx_la_SOURCES =  odbxlib.c odbxlib.h odbx.c odbxdrv.h
libopendbx_la_CFLAGS = @PKGCFLAGS@
libopendbx_la_CPPFLAGS = -DLIBPATH=\"$(pkglibdir)/\"
libopendbx_la_LDFLAGS = -version-info @LIBVERSION@

lib_LIBRARIES = libopendbx.a
libopendbx_a_SOURCES = odbxlib.c odbxlib.h odbx.c odbxdrv.h
libopendbx_a_CFLAGS = @PKGCFLAGS@
libopendbx_a_CPPFLAGS = -DODBX_STATIC
libopendbx_a_LDFLAGS = -static
libopendbx_a_LIBADD = $(top_builddir)/backends/mysql/libmysqlstatic.la


A Makefile.am of a backend:

pkglib_LTLIBRARIES = libmysqlbackend.la
libmysqlbackend_la_SOURCES = mysqlbackend.c mysqlbackend.h
libmysqlbackend_la_CFLAGS = @PKGCFLAGS@
libmysqlbackend_la_LDFLAGS = -module -version-info @LIBVERSION@
libmysqlbackend_la_LIBADD = address@hidden@

noinst_LTLIBRARIES = libmysqlstatic.la
libmysqlstatic_la_SOURCES = mysqlbackend.c mysqlbackend.h
libmysqlstatic_la_CFLAGS = @PKGCFLAGS@
libmysqlstatic_la_CPPFLAGS = -DODBX_STATIC
libmysqlstatic_la_LDFLAGS = -static
libmysqlstatic_la_LIBADD = address@hidden@


This generates an invalid libopendbx.a which contains the libopendbx object 
and an invalid libmysqlstatic.la file:

address@hidden:~/Project/opendbx/devel$ nm lib/libopendbx.a
libopendbx_a-odbx.o:
         U dcgettext
... (more functions)
00000110 T odbx_bind
nm: libmysqlstatic.la: File format not recognized

Which tells me that you are right and mixing .la and .a libraries is a bad 
idea.

So how do I get a valid static library (libopendbx.a) which contains all 
objects and doesn't fail when linking against a program:

make[2]: Entering directory `/home/nose/Project/opendbx/devel/test'
/bin/sh ../libtool --tag=CC --mode=link gcc -std=gnu99  -g -O2   -o 
odbxtest-static  odbx-regression.o ../lib/libopendbx.a
gcc -std=gnu99 -g -O2 -o odbxtest-static 
odbx-regression.o  ../lib/libopendbx.a
../lib/libopendbx.a(libopendbx_a-odbxlib.o):(.data+0x4): undefined reference 
to `mysql_odbx_ops'

Thanks for any help


Norbert
-- 
OpenPGP public key
http://www.linuxnetworks.de/norbert.pubkey.asc

Attachment: pgp5WH6X1A9mp.pgp
Description: PGP signature


reply via email to

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