Making and Using Libraries

1. Overview

A library contains a set of object files that implement functions and subroutines that can be linked with other object files to produce a complete executable program. In Windows, as in other modern operating systems, libraries may be either static or dynamic. The referenced object files from a static library are linked into your executable when it is built, but the routines in a dynamic library are not loaded until runtime.

In Windows, static library files have subscript .lib, whereas dynamic libraries use the subscript .dll. Executables that reference dynamic libraries are typically smaller than ones that reference static libraries because the object files from the dynamic library are not present. They will be loaded into memory at runtime directly from the dll file. Besides reduced program size, dynamic libraries have an additional advantage of promoting maintainability of code. If an error is found in a function that is used through a dynamic library, a corrected dll can be substituted for the original one and programs that formerly behaved incorrectly will be fixed without being rebuilt.