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


Inter-library dependencies

By definition, every shared library system provides a way for executables to depend on libraries, so that symbol resolution is deferred until runtime.

An inter-library dependency is one in which a library depends on other libraries. For example, if the libtool library `libhello' uses the cos(3) function, then it has an inter-library dependency on `libm', the math library that implements cos(3).

Some shared library systems provide this feature in an internally-consistent way: these systems allow chains of dependencies of potentially infinite length.

However, most shared library systems are restricted in that they only allow a single level of dependencies. In these systems, programs may depend on shared libraries, but shared libraries may not depend on other shared libraries.

In any event, libtool provides a simple mechanism for you to declare inter-library dependencies: for every library `libname' that your own library depends on, simply add a corresponding -lname option to the link line when you create your library.(5) To make an example of our `libhello' that depends on `libm':

burger$ libtool gcc -g -O -o libhello.la foo.lo hello.lo \
                -rpath /usr/local/lib -lm
burger$

In order to link a program against `libhello', you need to specify the same `-l' options, in order to guarantee that all the required libraries are found. This restriction is only necessary to preserve compatibility with static library systems and simple dynamic library systems.

If your library depends on symbols that are defined in executables or static libraries, then you cannot express the dependency with a `-lname' flag,(6) so you need to use the `-allow-undefined' link flag (see section Link mode).


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