[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Common Source code
Re: Common Source code
Fri, 12 May 2006 15:45:03 +0200
* Paulo J. Matos wrote on Fri, May 12, 2006 at 03:01:55PM CEST:
> On 12/05/06, Paulo J. Matos <address@hidden> wrote:
> >Ah, that's most probably what I need. Thanks a lot!
I don't know if you _need_ a convenience archive. You should not link
it into two different shared libraries that one program may later be
linked against (quoting info Libtool "Static libraries"):
| As a rule of thumb, link a libtool convenience library into at most
| one libtool library, and never into a program, and link libtool static
| convenience libraries only into programs, and only if you need to carry
| library dependency information to the user of the static convenience
That is because otherwise you are bound to get duplicate symbols
To avoid this, you can use a real library instead.
> After reading the chapter you mentioned and browsing the rest of the
> very nice book I implemented things that way and set up the structure
> (I'll forget lib2):
> |- lib
> | |- install-libs
> | | |- lib1
> | |- convenience-libs
> | |- liblogger
> |- src
Note while the book isn't so bad, it's quite old; this tutorial explains
newer autotools concepts:
> And I have only one Makefile.am in lib logger and the source files.
> The Makefile.am in liblogger is:
> noinst_LTLIBRARIES = liblogger.la
> libesatlogger_la_SOURCES = logger.cc logger.hh
> The configure.ac in lib1 specifies:
Nono. Don't specify ../../convenience-libs/liblogger/Makefile here.
> And in Makefile.am in lib1:
> SUBDIRS = ../../convenience-libs/liblogger src
The collective SUBDIRS listings in your source tree must form an acyclic
directed graph, i.e., a tree. As a rule of thumb, only specify direct
or insirect subdirectories of the current directory in SUBDIRS (i.e.,
containing no `../').
> Makefile of liblogger is generated OK, however I get an error:
> make: Entering directory
> make: *** No rule to make target `../../../../configure.ac', needed
> by `Makefile.in'. Stop.
> The problem is that the generated Makefile in liblogger has:
> top_srcdir = ../../../..
> And the top_srcdir is the one in lib1 which is ../../usable-libs/lib1
> and not ../../../..
> Probably liblogger would have to be inside the lib1 tree but what
> happens in lib2 also needs liblogger as a convinience library? Do I
> have to duplicate liblogger inside lib2 tree? Don't think this is the
> way to go.
> Is this a bug or a problem of my configuration?
Your setup isn't right.
If you want to ensure from within both lib1 and lib2 that liblogger is
up to date, you can add something of this form to their Makefile.am's:
cd ../../../liblogger/src && $(MAKE) $(AM_MAKEFLAGS) liblogger.la
(or possibly going into ../../../liblogger and issuing just `$(MAKE)
$(AM_MAKEFLAGS)', depending on your needs).
This has the disadvantage of not updating liblogger if it already
exists, since you don't provide the complete dependency information for
liblogger.la inside lib1's Makefile. You could declare the target
`../../../liblogger/src/liblogger.la' phony, or have it depend on
something that never exists; that would cause liblogger to be up to date
on each build of lib1, but it would also cause unnecessary rebuilds each
time you issue `make', at least with some make implementations.