Static linking versus using shared libraries

Static linking is the linking of a calling program and one or more called programs into a single executable module. When the program is loaded, the operating system places into memory a single file that contains the executable code and data.

The primary advantage of static linking is that you can use it to create self-contained, independent executable modules.

Static linking has these disadvantages, however:

To overcome these disadvantages, you can use shared libraries:

Shared libraries typically provide common functions that can be used by a number of programs. For example, you can use shared libraries to implement subprogram packages, subsystems, and interfaces in other programs or to create object-oriented class libraries.

Example: creating a sample shared library

related tasks  
Calling nonnested COBOL programs