libtool
[Top][All Lists]
Advanced

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

Re: Libtool Digest, Vol 3, Issue 35


From: Robert Boehne
Subject: Re: Libtool Digest, Vol 3, Issue 35
Date: Thu, 27 Feb 2003 08:55:40 -0600

Bill,

In general, Libtool won't prevent you from doing anything
that the linker can.  This works by passing flags through
Libtool with these flags:

`-Wl,FLAG'
`-Xlinker FLAG'
     Pass a linker specific flag directly to the linker.

`-XCClinker FLAG'
     Pass a link specific flag to the compiler driver (CC) during
     linking.

And another spot where convenience libraries are discussed:

Linking static libraries
========================

   Why return to `ar' and `ranlib' silliness when you've had a taste of
libtool?  Well, sometimes it is desirable to create a static archive
that can never be shared.  The most frequent case is when you have a
set of object files that you use to build several different programs.
You can create a "convenience library" out of those objects, and link
programs with the library, instead of listing all object files for
every program.  This technique is often used to overcome GNU automake's
lack of support for linking object files built from sources in other
directories, because it supports linking with libraries from other
directories.  This limitation applies to GNU automake up to release
1.4; newer releases should support sources in other directories.

   If you just want to link this convenience library into programs, then
you could just ignore libtool entirely, and use the old `ar' and
`ranlib' commands (or the corresponding GNU automake `_LIBRARIES'
rules).  You can even install a convenience library (but you probably
don't want to) using libtool:

     burger$ libtool --mode=install ./install-sh -c libhello.a
/local/lib/libhello.a
     ./install-sh -c libhello.a /local/lib/libhello.a
     ranlib /local/lib/libhello.a
     burger$

   Using libtool for static library installation protects your library
from being accidentally stripped (if the installer used the `-s' flag),
as well as automatically running the correct `ranlib' command.

   But libtool libraries are more than just collections of object files:
they can also carry library dependency information, which old archives
do not.  If you want to create a libtool static convenience library, you
can omit the `-rpath' flag and use `-static' to indicate that you're
only interested in a static library.  When you link a program with such
a library, libtool will actually link all object files and dependency
libraries into the program.

   If you omit both `-rpath' and `-static', libtool will create a
convenience library that can be used to create other libtool libraries,
even shared ones.  Just like in the static case, the library behaves as
an alias to a set of object files and dependency libraries, but in this
case the object files are suitable for inclusion in shared libraries.
But be careful not to link a single convenience library, directly or
indirectly, into a single program or library, otherwise you may get
errors about symbol redefinitions.

   When GNU automake is used, you should use `noinst_LTLIBRARIES'
instead of `lib_LTLIBRARIES' for convenience libraries, so that the
`-rpath' option is not passed when they are linked.

   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.

   Another common situation where static linking is desirable is in
creating a standalone binary.  Use libtool to do the linking and add the
`-all-static' flag.



Bill Northcott wrote:
> 
> >A convenience library is usually part of your own package,
> >it turns into a list of object files when you link to it.
> >It could be in a subdirectory, much like libltdl is for
> >many packages that use it.
> >Here is a section of the manual that mentions them:
> >http://www.gnu.org/software/libtool/manual.html#SEC14
> 
> Unfortunately all it does do is mention them!  It does not explain what it
> means or how to build or use them.  Is there any useful documentation?
> 
> What we are looking for on MacOS X is the ability to link a static library
> into a dylib with the -all-load flag, which ensures all symbols are loaded
> even if not referenced.  Having read the MacOS X ld docs, this is the only
> way to build a dylib which actually includes all the symbol definitions
> from some other library.
> I seem to remember seeing libtool use the -all-load flag, but I spent
> several hours reading what documentation there is and I can see no clues
> how to do this.
> 
> Bill Northcott
> 
> _______________________________________________
> Libtool mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/libtool




reply via email to

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