10.2.3 Creating Static Libraries

back: creating shared libraries with libtool
forward: creating convenience libraries with libtool
 
fastback: creating convenience libraries with libtool
up: the libtool library
fastforward: linking an executable
top: autoconf, automake, and libtool
contents: table of contents
index: index
about: about this document

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


GNU Autoconf, Automake and Libtool
GNU Autoconf, Automake, and Libtool
ISBN: 1578701902
EAN: 2147483647
Year: 2002
Pages: 290

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net