Autoconf, Automake, and Libtool: Creating Static Libraries with libtool

| ### 10.2.3 Creating Static Libraries In contrast, `libtool` will create a static library if either the ``-static'` or ``-all-static'` switches are specified on the link line for a Libtool library:
    $ libtool gcc -static -o libhello.la hello.lo
    rm -fr .libs/libhello.la .libs/libhello.* .libs/libhello.*
    ar cru .libs/libhello.a  hello.o
    ranlib .libs/libhello.a
    creating libhello.la
    (cd .libs && rm -f libhello.la && ln -s ../libhello.la libhello.la)
Note that since `libtool` will only create a static archive, the ``-rpath'` switch is not required: once a static library has been installed, there is no need to perform additional finalization for the library to be used from the installed location(16), or to track runtime search paths when installing a static archive. When you link an executable against this ``libhello.la'`, the objects from the static archive will be statically linked into the executable. The advantage of such a library over the traditional native static archive is that all of the dependency information from the Libtool library is used. For an example, See section Creating Convenience Libraries. `libtool` is useful as a general library building toolkit, yet people still seem to regress to the old way of building libraries whenever they want to use static archives. You should exploit the consistent interface of `libtool` even for static archives. If you don't want to use shared archives, use the ``-static'` switch to build a static Libtool library.

This document was generated by Gary V. Vaughan on May, 24 2001 using texi2html