In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computer, computing machinery. It includes the study and experimentation of algorithmic processes, and the development of both computer hardware, hardware and softw ...
, a library is a collection of
resources
''Resource'' refers to all the materials available in our environment which are Technology, technologically accessible, Economics, economically feasible and Culture, culturally Sustainability, sustainable and help us to satisfy our needs and want ...
that can be leveraged during
software development
Software development is the process of designing and Implementation, implementing a software solution to Computer user satisfaction, satisfy a User (computing), user. The process is more encompassing than Computer programming, programming, wri ...
to implement a
computer program
A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
. Commonly, a library consists of
executable
In computer science, executable code, an executable file, or an executable program, sometimes simply referred to as an executable or binary, causes a computer "to perform indicated tasks according to encoded instruction (computer science), in ...
code such as
compiled functions and
classes, or a library can be a collection of
source code
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
. A resource library may contain data such as
image
An image or picture is a visual representation. An image can be Two-dimensional space, two-dimensional, such as a drawing, painting, or photograph, or Three-dimensional space, three-dimensional, such as a carving or sculpture. Images may be di ...
s and
text
Text may refer to:
Written word
* Text (literary theory)
In literary theory, a text is any object that can be "read", whether this object is a work of literature, a street sign, an arrangement of buildings on a city block, or styles of clothi ...
.
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
A programmer, computer programmer or coder is an author of computer source code someone with skill in computer programming.
The professional titles Software development, ''software developer'' and Software engineering, ''software engineer' ...
only needs to know how to use it not its internal details. For example, a program could use a library that
abstracts a complicated
system call
In computing, a system call (syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, accessing a hard disk drive ...
so that the programmer can use the system feature without spending time to learn the intricacies of the system function.
History
The idea of a computer library dates back to the first computers created by
Charles Babbage
Charles Babbage (; 26 December 1791 – 18 October 1871) was an English polymath. A mathematician, philosopher, inventor and mechanical engineer, Babbage originated the concept of a digital programmable computer.
Babbage is considered ...
. An 1888 paper on his
Analytical Engine suggested that computer operations could be punched on separate cards from numerical input. If these operation punch cards were saved for reuse then "by degrees the engine would have a library of its own."

In 1947
Goldstine and
von Neumann speculated that it would be useful to create a "library" of
subroutine
In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times.
Callable units provide a ...
s for their work on the
IAS machine, an early computer that was not yet operational at that time. They envisioned a physical library of
magnetic wire recordings, with each wire storing reusable computer code.
Inspired by von Neumann,
Wilkes and his team constructed
EDSAC
The Electronic Delay Storage Automatic Calculator (EDSAC) was an early British computer. Inspired by John von Neumann's seminal ''First Draft of a Report on the EDVAC'', the machine was constructed by Maurice Wilkes and his team at the Universit ...
. A
filing cabinet
A filing cabinet (or sometimes file cabinet in American English) is a piece of office furniture for storing paper documents in file folders. In the most simple context, it is an enclosure for drawer (furniture), drawers in which articles are sto ...
of
punched tape
file:PaperTapes-5and8Hole.jpg, Five- and eight-hole wide punched paper tape
file:Harwell-dekatron-witch-10.jpg, Paper tape reader on the Harwell computer with a small piece of five-hole tape connected in a circle – creating a physical program ...
held the subroutine library for this computer. Programs for EDSAC consisted of a main program and a sequence of subroutines copied from the subroutine library. In 1951 the team published the first textbook on programming, ''
The Preparation of Programs for an Electronic Digital Computer
''The Preparation of Programs for an Electronic Digital Computer'' (sometimes called ''WWG'', after its authors' initials) was the first book on computer programming. Published in 1951, it was written by Maurice Wilkes, David Wheeler, and Stanl ...
'', which detailed the creation and the purpose of the library.
COBOL
COBOL (; an acronym for "common business-oriented language") is a compiled English-like computer programming language designed for business use. It is an imperative, procedural, and, since 2002, object-oriented language. COBOL is primarily ...
included "primitive capabilities for a library system" in 1959,
but
Jean Sammet described them as "inadequate library facilities" in retrospect.
[Wexelblat, ''op. cit.'', p. 258]
JOVIAL has a Communication Pool (COMPOOL), roughly a library of header files.
Another major contributor to the modern library concept came in the form of the
subprogram innovation of
FORTRAN. FORTRAN subprograms can be compiled independently of each other, but the compiler lacked a
linker
Linker or linkers may refer to:
Computing
* Linker (computing), a computer program that takes one or more object files generated by a compiler or generated by an assembler and links them with libraries, generating an executable program or shar ...
. So prior to the introduction of modules in Fortran-90,
type checking
In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a ''type'' (for example, integer, floating point, string) to every '' term'' (a word, phrase, or other set of symbols). Usu ...
between FORTRAN
[It was possible earlier between, e.g., Ada subprograms.] subprograms was impossible.
By the mid 1960s, copy and macro libraries for assemblers were common. Starting with the popularity of the
IBM System/360
The IBM System/360 (S/360) is a family of mainframe computer systems announced by IBM on April 7, 1964, and delivered between 1965 and 1978. System/360 was the first family of computers designed to cover both commercial and scientific applicati ...
, libraries containing other types of text elements, e.g., system parameters, also became common.
In
IBM's OS/360 and its successors this is called a
partitioned data set.
The first
object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impl ...
language,
Simula
Simula is the name of two simulation programming languages, Simula I and Simula 67, developed in the 1960s at the Norwegian Computing Center in Oslo, by Ole-Johan Dahl and Kristen Nygaard. Syntactically, it is an approximate superset of AL ...
, developed in 1965, supported adding
classes to libraries via its compiler.
[Wilson and Clark, ''op. cit.'', p. 52][Wexelblat, ''op. cit.'', p. 716]
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
Linker or linkers may refer to:
Computing
* Linker (computing), a computer program that takes one or more object files generated by a compiler or generated by an assembler and links them with libraries, generating an executable program or shar ...
(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.
Categories
Executable
An executable library consists of code that has been converted from source code into
machine code
In computer programming, machine code is computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonb ...
or an intermediate form such as
bytecode
Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
. A linker allows for using library objects by associating each reference with an address at which the object is located. For example, in
C, a library function is invoked via C's normal function call
syntax
In linguistics, syntax ( ) is the study of how words and morphemes combine to form larger units such as phrases and sentences. Central concerns of syntax include word order, grammatical relations, hierarchical sentence structure (constituenc ...
and
semantics
Semantics is the study of linguistic Meaning (philosophy), meaning. It examines what meaning is, how words get their meaning, and how the meaning of a complex expression depends on its parts. Part of this process involves the distinction betwee ...
.
A variant is a library containing compiled code (object code in IBM's nomenclature) in a form that cannot be loaded by the OS but that can be read by the linker.
Static
A
static library
A static library or statically linked library contains functions and data that can be included in a consuming computer program at build-time such that the library does not need to be accessible in a separate file at run-time. If all libraries a ...
is an executable library that is linked into a program at build-time by a linker (or whatever the build tool is called that does linking).
This process, and the resulting stand-alone file, is known as a
static build of the program. A static build may not need any further
relocation if
virtual memory
In computing, virtual memory, or virtual storage, is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a ver ...
is used and no
address space layout randomization is desired.
A static library is sometimes called an ''archive'' on Unix-like systems.
Dynamic
A
dynamic library is linked when the program is run either at
load-time or
runtime. The dynamic library was intended after the static library to support additional
software deployment flexibility.
Sources
A source library consists of source code; not compiled code.
Shared
A
shared library
In computing, a library is a collection of System resource, resources that can be leveraged during software development to implement a computer program. Commonly, a library consists of executable code such as compiled function (computer scienc ...
is a library that contains
executable code designed to be used by multiple
computer program
A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
s or other libraries at
runtime, with only one copy of that code in memory, shared by all programs using the code.
Object
Although generally an obsolete technology today, an object library exposes resources for
object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impl ...
(OOP) and a distributed object is a remote object library. Examples include:
COM/DCOM,
SOM/DSOM,
DOE,
PDO and various
CORBA-based systems.
The object library technology was developed since as OOP became popular, it became apparent that OOP runtime binding required information than contemporary libraries did not provide. In addition to the names and entry points of the code located within, due to inheritance, OOP binding also requires a list of dependencies since the full definition of a method may be in different places. Further, this requires more than listing that one library requires the services of another. In OOP, the libraries themselves may not be known at
compile time
In computer science, compile time (or compile-time) describes the time window during which a language's statements are converted into binary instructions for the processor to execute. The term is used as an adjective to describe concepts relat ...
, and vary from system to system.
The remote object technology was developed in parallel to support multi-tier programs with a
user interface
In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine fro ...
application running on a
personal computer
A personal computer, commonly referred to as PC or computer, is a computer designed for individual use. It is typically used for tasks such as Word processor, word processing, web browser, internet browsing, email, multimedia playback, and PC ...
(PC) using services of a
mainframe
A mainframe computer, informally called a mainframe or big iron, is a computer used primarily by large organizations for critical applications like bulk data processing for tasks such as censuses, industry and consumer statistics, enterpris ...
or
minicomputer such as data storage and processing. For instance, a program on a PC would send messages to a minicomputer via
remote procedure call
In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure (subroutine) to execute in a different address space (commonly on another computer on a shared computer network), which is written as if it were a ...
(RPC) to retrieve relatively small samples from a relatively large dataset. In response, distrubuted object technology was developed.
Class
A class library contains
classes that can be used to create
objects. In
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, for example, classes are contained in
JAR files and objects are created at runtime from the classes. However, in
Smalltalk
Smalltalk is a purely object oriented programming language (OOP) that was originally created in the 1970s for educational use, specifically for constructionist learning, but later found use in business. It was created at Xerox PARC by Learni ...
, a class library is the starting point for a
system image that includes the entire state of the environment, classes and all instantiated objects. Most class libraries are stored in a
package repository (such as Maven Central for Java). Client code explicitly specifies dependencies to external libraries in build configuration files (such as a Maven Pom in Java).
Remote
A remote library runs on another computer and its assets are accessed via
remote procedure call
In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure (subroutine) to execute in a different address space (commonly on another computer on a shared computer network), which is written as if it were a ...
(RPC) over a network. This
distributed architecture allows for minimizing installation of the library and support for it on each consuming system and ensuring consistent versioning. A significant downside is that each library call entails significantly more overhead than for a local library.
Runtime
A
runtime library provides access to the
runtime environment
In computer programming, a runtime system or runtime environment is a sub-system that exists in the computer where a program is created, as well as in the computers where the program is intended to be run. The name comes from the compile time ...
that is available to a program tailored to the host
platform.
Language standard
Many modern
programming languages specify a
standard library
In computer programming, a standard library is the library (computing), library made available across Programming language implementation, implementations of a programming language. Often, a standard library is specified by its associated program ...
that provides a base level of functionality for the language environment.
Code generation
A code generation library has a high-level
API
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
generating or transforming
byte code for
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
. They are used by
aspect-oriented programming, some data access frameworks, and for testing to generate dynamic proxy objects. They also are used to intercept field access.
File naming
Unix-like
On most modern
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
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
An archive is an accumulation of historical records or materials, in any medium, or the physical facility in which they are located.
Archives contain primary source documents that have accumulated over the course of an individual or organ ...
) or
.so
for a shared object (dynamically linked library). For example,
libfoo.a
and
libfoo.so
.
Often,
symbolic link
In computing, a symbolic link (also symlink or soft link) is a file whose purpose is to point to a file or directory (called the "target") by specifying a path thereto.
Symbolic links are supported by POSIX and by most Unix-like operating syste ...
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 extension
.la
are
libtool archives; not usable by the system.
macOS
The
macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
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
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
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
Notes
References
Further reading
* Code
ftp://ftp.iecc.com/pub/linker/] Errata
https://archive.today/20200114224817/https://linker.iecc.com/ 2020-01-14 -->* Article
' by David Drysdale
* Article
' by Léon Bottou and John Ryland
* by Baris Simsek
- the Binary File Descriptor Library
1st Library-Centric Software Design Workshop LCSD'05 at OOPSLA'05
2nd Library-Centric Software Design Workshop LCSD'06at OOPSLA'06
How to create shared libraryby Ulrich Drepper (with much background info)
Anatomy of Linux dynamic librariesat IBM.com
{{DEFAULTSORT:Library (Computing)
Computer libraries,
Operating system technology