Shared library

A shared library or shared object is a computer file that contains executable code designed to be used by multiple computer programs or other libraries at runtime.

When running a program that is configured to use a shared library, the operating system loads the shared library from a file (other than the program's executable file) into memory at load time or runtime. For perspective, a program can alternatively be monolithic -- built to include the executable code of the library in its executable file, but the library code embedded in the program's executable file is not usable by other programs.

Shared libraries can be statically linked at compile-time, meaning that references to the library are resolved and the library is allocated memory when the executable file is created.[citation needed] But often linking of shared libraries is postponed until they are loaded.[dubiousdiscuss]

Most modern operating systems use the same format for both shared libraries and executable files.[NB 1] This offers two main advantages: first, it requires only one loader (building and maintaining a single loader is considered well worth any added complexity)[citation needed]. Secondly, it allows an executable file to be used as a shared library (if it has a symbol table). Examples of file formats use for both shared libraries and executable files include ELF, Mach-O, and PE.

In some older environments such as 16-bit Windows or MPE for the HP 3000, only stack-based data (local) was allowed in shared library code, or other significant restrictions were placed on shared library code.
Cite error: There are <ref group=NB> tags on this page, but the references will not show without a {{reflist|group=NB}} template (see the help page).


Developed by StudentB