Next: , Previous: Libtool Concept, Up: A Shared Library

8.3.2 Building Libtool Libraries

Automake uses libtool to build libraries declared with the LTLIBRARIES primary. Each _LTLIBRARIES variable is a list of libtool libraries to build. For instance, to create a libtool library named, and install it in libdir, write:

     lib_LTLIBRARIES =
     libgettext_la_SOURCES = gettext.c gettext.h ...

Automake predefines the variable pkglibdir, so you can use pkglib_LTLIBRARIES to install libraries in ‘$(libdir)/@PACKAGE@/’.

If gettext.h is a public header file that needs to be installed in order for people to use the library, it should be declared using a _HEADERS variable, not in libgettext_la_SOURCES. Headers listed in the latter should be internal headers that are not part of the public interface.

     lib_LTLIBRARIES =
     libgettext_la_SOURCES = gettext.c ...
     include_HEADERS = gettext.h ...

A package can build and install such a library along with other programs that use it. This dependency should be specified using LDADD. The following example builds a program named hello that is linked with

     lib_LTLIBRARIES =
     libgettext_la_SOURCES = gettext.c ...
     bin_PROGRAMS = hello
     hello_SOURCES = hello.c ...
     hello_LDADD =

Whether hello is statically or dynamically linked with is not yet known: this will depend on the configuration of libtool and the capabilities of the host.