Program Library HOWTO

David A. Wheeler

version 1.20, 11 April 2003

This HOWTO for programmers discusses how to create and use program libraries on Linux. This includes static libraries, shared libraries, and dynamically loaded libraries.


Table of Contents
1. Introduction
2. Static Libraries
3. Shared Libraries
3.1. Conventions
3.2. How Libraries are Used
3.3. Environment Variables
3.4. Creating a Shared Library
3.5. Installing and Using a Shared Library
3.6. Incompatible Libraries
4. Dynamically Loaded (DL) Libraries
4.1. dlopen()
4.2. dlerror()
4.3. dlsym()
4.4. dlclose()
4.5. DL Library Example
5. Miscellaneous
5.1. nm command
5.2. Library constructor and destructor functions
5.3. Shared Libraries Can Be Scripts
5.4. Symbol Versioning and Version Scripts
5.5. GNU libtool
5.6. Removing symbols for space
5.7. Extremely small executables
5.8. C++ vs. C
5.9. Speeding up C++ initialization
5.10. Linux Standard Base (LSB)
6. More Examples
6.1. File libhello.c
6.2. File libhello.h
6.3. File demo_use.c
6.4. File script_static
6.5. File script_shared
6.6. File demo_dynamic.c
6.7. File script_dynamic
7. Other Information Sources
8. Copyright and License