9.3. Linking an Executable

Continuing the parallel between the syntax used to compile with libtool and the syntax used when building old static libraries, linking an executable is a matter of combining compilation units into a binary in both cases. We tell the compiler which objects and libraries are required, and it creates an executable for us.

Hands On

If you want to try this to see what libtool does on your machine, put the following code in a file 'main.c' in the same directory as 'hello.c' and 'libhello.la', and run the example shell commands from there:

void hello ();

int
main (argc, argv)
     int argc;
     char *argv[];
{
  hello ("World");
  exit (0);
}

To compile an executable that uses the non-Libtool 'libhello.a' library built previously, I ...

Get GNU Autoconf, Automake, and Libtool now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.