Go to the first, previous, next, last section, table of contents.


Building a Shared Library

Building shared libraries is a relatively complex matter. For this reason, GNU Libtool (see section `Introduction' in The Libtool Manual) was created to help build shared libraries in a platform-independent way.

Automake uses Libtool to build libraries declared with the `LTLIBRARIES' primary. Each `_LTLIBRARIES' variable is a list of shared libraries to build. For instance, to create a library named `libgettext.a' and its corresponding shared libraries, and install them in `libdir', write:

lib_LTLIBRARIES = libgettext.la

Note that shared libraries must be installed, so check_LTLIBRARIES is not allowed. However, noinst_LTLIBRARIES is allowed. This feature should be used for libtool "convenience libraries".

For each library, the `library_LIBADD' variable contains the names of extra libtool objects (`.lo' files) to add to the shared library. The `library_LDFLAGS' variable contains any additional libtool flags, such as `-version-info' or `-static'.

Where an ordinary library might include @LIBOBJS@, a libtool library must use @LTLIBOBJS@. This is required because the object files that libtool operates on do not necessarily end in `.o'. The libtool manual contains more details on this topic.

For libraries installed in some directory, Automake will automatically supply the appropriate `-rpath' option. However, for libraries determined at configure time (and thus mentioned in EXTRA_LTLIBRARIES), Automake does not know the eventual installation directory; for such libraries you must add the `-rpath' option to the appropriate `_LDFLAGS' variable by hand.

Ordinarily, Automake requires that a shared library's name start with `lib'. However, if you are building a dynamically loadable module then you might wish to use a "nonstandard" name. In this case, put -module into the `_LDFLAGS' variable.

See section `The Libtool Manual' in The Libtool Manual, for more information.


Go to the first, previous, next, last section, table of contents.