Chapter 3. Building All Kinds of Libraries — libtool

Table of Contents

1. libtool wrappers
2. Building plugins
3. Exposing and Hiding Symbols
4. Library Versioning
5. Notes on Windows Support
6. Libtool Archives

While autotools are vastly considered black magic, because they tend to show a black box abstracting lots of details about compilers, makefiles and dependencies, the component that can be truly said to be black magic is certainly libtool.

The libtool script is a huge script that allows the developers to ignore, at least partially, all the complex details related to shared objects and their creation. This is needed because this is one of the areas that changes most between operating systems, both in terms of actual technical requirements and in terms of conventions.

Note

Among the different conventions between different operating systems, the first one to disambiguate is the name used to identify these types of files; almost every other operating system changed the name used.

Unix systems classically called these shared objects and this is the name that will be used in this guide. People more involved in another operating system might know them as “dynamically-linked libraries” (DLL) or simply “dynamic libraries”.

Some (older) operating systems might not provide any support for shared objects at all; others might require they be built in a specific (non-default) file format. Some architectures insist that shared objects are built with Position-Independent Code (a feature enabled by the compiler). For those operating systems that do support them, the versioning rules might vary enormously.

All these details make it difficult to simply build shared objects in the same way on all operating systems, and here is where libtool enters the scene: the libtool script is a frontend to various compilers and linkers that takes care of abstracting most of the syntax, and of the details for building the libraries.

Because of these changes, the libtool package is probably the most complex part of the autotools stack, and also one that is often avoided by those looking for a simpler build system.

Warning

OpenBSD is known as of July 2012 to use their own implementation of libtool which is not 100% compatible with the original GNU implementation.

Unless otherwise stated, all the documentation in this guide and in particular in this chapter is discussing the original GNU projects and packages, and might or might not apply to OpenBSD's own versions.