Back: Creating Libtool Libraries with Automake
Forward: Using libtoolize
FastBack: Using libtoolize
Up: Integration with
FastForward: Using libtoolize
Top: Autoconf, Automake, and Libtool
Contents: Table of Contents
Index: Index
About: About this document

11.2.2 Linking against Libtool Libraries with Automake

Once you have set up your `' to create some Libtool libraries. you will want to link an executable against them. You can do this easily with automake by using the program's qualified `LDADD' macro:

bin_PROGRAMS  = shell
shell_SOURCES = shell.c token.l
shell_LDADD   =

This will choose either the static or shared archive from the `' Libtool library depending on the target host and any Libtool mode switches mentioned in the `', or passed to configure. The chosen archive will be linked with any objects generated from the listed sources to make an executable. Note that the executable itself is a hidden file, and that in its place libtool creates a wrapper script, See section 10.5 Executing Uninstalled Binaries.

As with the Libtool libraries, you can pass additional switches for the libtool invocation in the qualified `LDFLAGS' macros to control how the shell executable is linked:

Always choose static libraries where possible, and try to create a completely statically linked executable.

If you really want to use this flag on some targets, you can pass it in an `LDFLAGS' macro. This is not overridden by the configure `--enable-fast-install' switch. Executables built with this flag will not need relinking to be executed from the build tree on platforms which might have otherwise required it.

You should use this option for any executables which are used only for testing, or for generating other files and are consequently never installed. By specifying this option, you are telling Libtool that the executable it links will only ever be executed from where it is built in the build tree. Libtool is usually able to considerably speed up the link process for such executables.

This switch is similar to `-all-static', except that it applies to only the uninstalled Libtool libraries in the build tree. Where possible the static archive from these libraries is used, but the default linking mode is used for libraries which are already installed.

When debugging an executable, for example, it can be useful to temporarily use:

shell_LDFLAGS = -all-static

You can pass Libtool link options to all of the targets in a given directory by using the unadorned `LDFLAGS' macro:

LDFLAGS = -static

This is best reserved for directories which have targets of the same type, all Libtool libraries or all executables for instance. The technique still works in a mixed target type directory, and libtool will ignore switches which don't make sense for particular targets. It is less maintainable, and makes it harder to understand what is going on if you do that though.

This document was generated by Gary V. Vaughan on February, 8 2006 using texi2html