Back: Creating libtool
Forward: Position Independent Code
 
FastBack: Linking an Executable
Up: Introducing GNU Libtool
FastForward: Linking an Executable
Top: Autoconf, Automake, and Libtool
Contents: Table of Contents
Index: Index
About: About this document

10.2 The Libtool Library

A Libtool library is built from Libtool objects in the same way that a native (non-Libtool) library is built from native objects. Building a Libtool library with libtool is as easy as building an old style static archive. Generally, each of the sources is compiled to a Libtool object, and then these objects are combined to create the library.

If you want to try this to see what libtool does on your machine, put the following code in a file `hello.c', in a directory of its own, and run the example shell commands from there:

 
#include <stdio.h>

void
hello (char *who)
{
  printf ("Hello, %s!\n", who);
}


The traditional way to make a (native) static library is as follows:

 
$ gcc -c hello.c
$ ls
hello.c  hello.o
$ ar cru libhello.a hello.o
$ ranlib libhello.a
$ ls
hello.c   hello.o   libhello.a

Notice that even when I just want to build an old static archive, I need to know that, in common with most Unices, I have to bless(14) my library with ranlib to make it work optimally on HP-UX.

Essentially, Libtool supports the building of three types of library: shared libraries; static libraries; and convenience libraries. In the following sections I will talk about each in turn, but first you will need to understand how to create and use position independent code, as explained in the next section.


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