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

Re: PROPOSAL: libtool archive (`*.la) files in `-dev' packages



Oops, forgot to amswer this:

On 06-May-99 Joey Hess wrote:
> As far as I can see linux's shared library format allows specification of
> inter-library dependancies. So I hope an example is forthcoming..

Linux elf libraries do not (reliably) allow interlibrary dependencies between
shared and static libraries.  libtool libraries do, provided the meta-data in
the .la files is left intact.  For example:

        we have two libraries:  liba.a and libb.so (libb depends on liba)
        and a binary which needs both: foo

    with linux elf alone:

        ar cru liba,a a1.o a2.o && ranlib liba.a
        cc -shared -o libb.so b1.o b2.o liba.a
        cc -o foo foo.o libb.so liba.a

        note that we have to remember to add liba.a to the link line whenever
        we want to link libb.so, and that foo will likely SEGV if a1.o and a2.o
        were not -fpic (whcih they shouldn't be for a static lib).

    with libtool on linux (syntax is from memory):

        libtool --mode=link -static -o liba.la a1.o a2.o
        libtool --mode=link -o libb.la b1.lo b2.lo liba.la
        libtool --mode=link -o foo foo.o libb.la

        note that libb.la notes the dependency on liba.a but doesn't actually
        link the library until foo itself is linked avoiding the SEGV.  This
        also works on any host to which libtool has been ported (e.g. BeOS,
        win32, DOS etc) without makefile changes,

See http://www.gnu.org/software/libtool/deplibs.html for more details about the
intricacies of inter-library dependencies.

Cheers,
        Gary.
-- 
  ___              _   ___   __              _  email:gary@oranda.demon.co.uk
 / __|__ _ _ ___ _| | / / | / /_ _ _  _ __ _| |_  __ _ ___       gary@gnu.org 
| (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
 \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
home page:  /___/                      /___/                pgp-2 public key:
http://www.oranda.demon.co.uk               http://www.oranda.demon.co.uk/pgp


Reply to: