Library (computing)

file In computing, a library is a collection of resources that can be used during software development to implement a computer program.

Uses your system voice; voice and rate in settings.

≈ 5 min read

Cite, export and learn8 citation formats · 8 exports · lesson and quiz

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

file In computing, a library is a collection of resources that can be used during software development to implement a computer program. Commonly, a library consists of executable code such as compiled functions and classes, or a library can be a collection of source code. A resource library may contain data such as images and text.

A library can be used by multiple, independent consumers (programs and other libraries). This differs from resources defined in a program which can usually only be used by that program. When a consumer uses a library resource, it gains the value of the library without having to implement it itself.

Libraries encourage software reuse in a modular fashion. Libraries can use other libraries resulting in a hierarchy of libraries in a program. When writing code that uses a library, a programmer only needs to know how to use that library's application programming interface (API) without understanding its internal mechanics.

For example, a program could use a library that abstracts a complicated system call so that the programmer can use the system feature without spending time to learn the intricacies of the system function.

Linking

The linking (or binding) process resolves references known as symbols (or links) by searching for them in various locations including configured libraries. If a linker (or binder) does not find a symbol, then it fails, but multiple matches may or may not cause failure. Static linking is linking at build time, such that the library executable code is included in the program.

Dynamic linking is linking at run time; it involves building the program with information that supports run-time linking to a dynamic link library (DLL). For dynamic linking, a compatible DLL file must be available to the program at run time, but for static linking, the program is standalone. Smart linking is performed by a build tool that excludes unused code in the linking process.

For example, a program that only uses integers for arithmetic, or does no arithmetic operations at all, can exclude floating-point library routines. This can lead to smaller program file size and reduced memory usage.

Relocation

Some references in a program or library module are stored in a relative or symbolic form which cannot be resolved until all code and libraries are assigned final static addresses. Relocation is the process of adjusting these references, and is done either by the linker or the loader.

In general, relocation cannot be done to individual libraries themselves because the addresses in memory may vary depending on the program using them and other libraries they are combined with. Position-independent code avoids references to absolute addresses and therefore does not require relocation.

Unix-like

On most modern Unix-like systems, library files are stored in directories such as /lib , /usr/lib and /usr/local/lib . A filename typically starts with lib , and ends with .a for a static library (archive) or .so for a shared object (dynamically linked library). For example, libfoo.a and libfoo.so .

Often, symbolic link files are used to manage versioning of a library by providing a link file named without a version that links to a file named with a version. For example, libfoo.so.2 might be version 2 of library foo and a link file named libfoo.so provides a version independent name to that file that programs link to.

The link file could be changed to a refer to a version 3 ( libfoo.so.3 ) such that consuming programs will then use version 3 without having to change the program. Files with the extension .la are libtool archives; they are not usable by the system.

macOS

The macOS system inherits static library conventions from BSD, with the library stored in a .a file. It uses either .so or .dylib for dynamic libraries. Most libraries in macOS, however, consist of "frameworks", placed inside special directories called "bundles" which wrap the library's required files and metadata.

For example, a framework called Abc would be implemented in a bundle called Abc.framework , with Abc.framework/Abc being either the dynamically linked library file or a symlink to the dynamically linked library file in Abc.framework/Versions/Current/Abc .

Windows

Often, a Windows dynamic-link library (DLL) has the file extension .dll , although sometimes different extensions are used to indicate general content, e.g. .ocx for a OLE library. A .lib file can be either a static library or contain the information needed to build an application that consumes the associated DLL. In the latter case, the associated DLL file must be present at runtime.

See also

(VCL) (CLX) (used by the C++ Standard Library) List of open source code libraries

Further reading

Code: [ftp://ftp.iecc.com/pub/linker/] Errata: Article Beginner's Guide to Linkers by David Drysdale Article Faster C++ program startups by improving runtime linking efficiency by Léon Bottou and John Ryland by Baris Simsek BFD - the Binary File Descriptor Library 1st Library-Centric Software Design Workshop LCSD'05 at OOPSLA'05 2nd Library-Centric Software Design Workshop LCSD'06 at OOPSLA'06 How to create shared library by Ulrich Drepper (with much background info) Anatomy of Linux dynamic libraries at IBM.com

Text derived from https://en.wikipedia.org/w/index.php?oldid=1365619090 under CC BY-SA 4.0; modifications have been made.

Words in each sectionLinkingLinkingLinking: 160 words160Unix-likeUnix-likeUnix-like: 158 words158Further readingFurther readingFurther reading: 110 words110macOSmacOSmacOS: 95 words95RelocationRelocationRelocation: 91 words91WindowsWindowsWindows: 64 words64See alsoSee alsoSee also: 14 words14
Words in each section. Measured from the stored article body; sections below the minimum are not plotted.

Provenance

snapshot enwiki-001365619090 · captured 2026-07-23 · ledger · version history

Cite this page as: encyclopegia.org, “Library (computing)”, snapshot enwiki-001365619090. https://encyclopegia.org/a/library-computing

Sources cited in this revision

13 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.