|
10. Introducing GNU Libtool
Libtool takes care of all the peculiarities of creating, linking and
loading shared and static libraries across a great number of platforms,
providing a uniform command line interface to the developer. By using
Libtool to manage your project libraries, you only need to concern
yourself with Libtool's interface: when someone else builds your
project on a platform with a different library architecture, Libtool
invokes that platform's compiler and linker with the correct environment
and command line switches. It will install libraries and library using
binaries according to the conventions of the host platform, and follows
that platform's rules for library versioning and library
interdependencies.
Libtool empowers you to treat a library as an implementation of a well
defined interface of your choosing. This Libtool library may be
manifest as a collection of compiler objects, a static ar
archive, or a position independent runtime loadable object. By
definition, native libraries are fully supported by Libtool since
they are an implementation detail of the Libtool library
abstraction. It's just that until Libtool achieves complete world
domination, you might need to bear in mind what is going on behind the
command line interface when you first add Libtool support to your
project.
The sheer number of uses of the word `library' in this book could
be easily very confusing. In this chapter and throughout the rest of
the book, I will refer to various kinds of libraries as follows:
- `native'
- Low level libraries, that is, libraries provided by the host
architecture.
- `Libtool library'
- The kind of library built by Libtool. This encompasses both the
shared and static native components of the implementation of the named
library.
- `pseudo-library'
- The high level `.la' file produced by Libtool. The
`pseudo-library' is not a library in its own right, but is treated
as if it were from outside the Libtool interface.
Futhermore, in the context of Libtool, there is another subtle (but
important) distinction to be drawn:
- `static library'
- A Libtool library which has no shared archive component.
- `static archive'
- The static component of a Libtool library.
Many developers use Libtool as a black box which requires adding a few
macros to `configure.in' and tweaking a project's
`Makefile.am'. The next chapter addresses that school of thought
in more detail. In this chapter I will talk a little about the inner
workings of Libtool, and show you how it can be used directly from your
shell prompt -- how to build various kinds of library, and how those
libraries can be used by an application. Before you can do any of this,
you need to create a libtool script that is tailored to the
platform you are using it from.
|