libtool: Inter-library dependencies

1 
1 9 Inter-library dependencies
1 ****************************
1 
1 By definition, every shared library system provides a way for
1 executables to depend on libraries, so that symbol resolution is
1 deferred until runtime.
1 
1    An "inter-library dependency" is where a library depends on other
1 libraries.  For example, if the libtool library 'libhello' uses the
1 'cos' function, then it has an inter-library dependency on 'libm', the
1 math library that implements 'cos'.
1 
1    Some shared library systems provide this feature in an
1 internally-consistent way: these systems allow chains of dependencies of
1 potentially infinite length.
1 
1    However, most shared library systems are restricted in that they only
1 allow a single level of dependencies.  In these systems, programs may
1 depend on shared libraries, but shared libraries may not depend on other
1 shared libraries.
1 
1    In any event, libtool provides a simple mechanism for you to declare
1 inter-library dependencies: for every library 'libNAME' that your own
1 library depends on, simply add a corresponding '-lNAME' option to the
1 link line when you create your library.  To make an example of our
1 'libhello' that depends on 'libm':
1 
1      burger$ libtool --mode=link gcc -g -O -o libhello.la foo.lo hello.lo \
1                      -rpath /usr/local/lib -lm
1      burger$
1 
1    When you link a program against 'libhello', you don't need to specify
1 the same '-l' options again: libtool will do that for you, to guarantee
1 that all the required libraries are found.  This restriction is only
1 necessary to preserve compatibility with static library systems and
1 simple dynamic library systems.
1 
1    Some platforms, such as Windows, do not even allow you this
1 flexibility.  In order to build a shared library, it must be entirely
1 self-contained or it must have dependencies known at link time (that is,
1 have references only to symbols that are found in the '.lo' files or the
1 specified '-l' libraries), and you need to specify the '-no-undefined'
1 flag.  By default, libtool builds only static libraries on these kinds
1 of platforms.
1 
1    The simple-minded inter-library dependency tracking code of libtool
1 releases prior to 1.2 was disabled because it was not clear when it was
1 possible to link one library with another, and complex failures would
1 occur.  A more complex implementation of this concept was re-introduced
1 before release 1.3, but it has not been ported to all platforms that
1 libtool supports.  The default, conservative behavior is to avoid
1 linking one library with another, introducing their inter-dependencies
1 only when a program is linked with them.
1