By using linking, you can have a program call another program that is not contained in the source code of the calling program. Before or during execution, the object module of the calling program is linked with the object module of the called program.
Static linking occurs when a calling program is linked to a called program in 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 result of statically linking programs is an .EXE file or dynamic link library (DLL) subprogram that contains the executable code for multiple programs. This file includes both the calling program and the called program.
The primary advantage of static linking is that you can create self-contained, independent programs. In other words, the executable program consists of one part (the .EXE file) that you need to keep track of. Static linking has these disadvantages:
To overcome these disadvantages, use dynamic linking.
Dynamic linking lets several programs use a single copy of an executable module. The executable module is separate from the programs that use it. You can build several subprograms into a DLL. Calling programs can use these subprograms as if they were part of the executable code of the calling program. You can change the dynamically linked subprograms without recompiling or relinking the calling program.
DLLs are typically used to provide common functions for a number of programs. For example, you can use DLLs to implement subprogram packages, subsystems, and interfaces to other programs, or to create object-oriented class libraries.
You can dynamically link files with the supplied runtime DLLs and with your own COBOL DLLs.
related concepts
CALL identifier and CALL literal
How the linker resolves references to DLLs
related tasks
Creating DLLs