[Top][All Lists]

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

Re: Common Source code

From: Ralf Wildenhues
Subject: Re: Common Source code
Date: Fri, 12 May 2006 15:45:03 +0200
User-agent: Mutt/1.5.11

* 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
| library.

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):
> tree
> |- 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 in lib logger and the source files.
> The in liblogger is:
> noinst_LTLIBRARIES =
> libesatlogger_la_SOURCES = logger.hh
> The in lib1 specifies:
>                                       src/Makefile
> ../../convenience-libs/liblogger/Makefile])

Nono.  Don't specify ../../convenience-libs/liblogger/Makefile here.

> And in 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[2]: Entering directory 
> `/home/pmatos/soft/lib/convenience-libs/liblogger'
> make[2]: *** No rule to make target `../../../../', needed
> by `'.  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's:

        cd ../../../liblogger/src && $(MAKE) $(AM_MAKEFLAGS)

(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 inside lib1's Makefile.  You could declare the target
`../../../liblogger/src/' 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.


reply via email to

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