HOME

TheInfoList




In
computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of , , and . Computer science ...
, a library is a collection of
non-volatile Non-volatile memory (NVM) or non-volatile storage is a type of computer memory In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of ...
resources used by
computer program In imperative programming, a computer program is a sequence of instructions in a programming language that a computer can execute or interpret. In declarative programming, a ''computer program'' is a Set (mathematics), set of instructions. A comp ...
s, often for
software development Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications Application may refer to: Mathematics and computing * Application ...
. These may include configuration data, documentation, help data, message templates, pre-written code and
subroutine In computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a particular task. Programming involves tasks such as analysis, generat ...
s,
classes Class or The Class may refer to: Common uses not otherwise categorized * Class (biology), a taxonomic rank * Class (knowledge representation), a collection of individuals or objects * Class (philosophy), an analytical concept used differently f ...
,
values In ethics Ethics or moral philosophy is a branch of philosophy Philosophy (from , ) is the study of general and fundamental questions, such as those about Metaphysics, existence, reason, Epistemology, knowledge, Ethics, values, Philosophy ...
or
type Type may refer to: Science and technology Computing * Typing, producing text via a keyboard, typewriter, etc. * Data type, collection of values used for computations. * File type * TYPE (DOS command), a command to display contents of a file. * Type ...
specifications. In IBM's OS/360 and its successors they are referred to as partitioned data sets. A library is also a collection of implementations of behavior, written in terms of a language, that has a well-defined
interface Interface or interfacing may refer to: Academic journals * Interface (journal), ''Interface'' (journal), by the Electrochemical Society * ''Interface, Journal of Applied Linguistics'', now merged with ''ITL International Journal of Applied Lin ...
by which the behavior is invoked. For instance, people who want to write a higher-level program can use a library to make
system call In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and soft ...
s instead of implementing those system calls over and over again. In addition, the behavior is provided for reuse by multiple independent programs. A program invokes the library-provided behavior via a mechanism of the language. For example, in a simple
imperative language In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of Algorit ...
such as C, the behavior in a library is invoked by using C's normal function-call. What distinguishes the call as being to a library function, versus being to another function in the same program, is the way that the code is organized in the system. Library code is organized in such a way that it can be used by multiple programs that have no connection to each other, while code that is part of a program is organized to be used only within that one program. This distinction can gain a hierarchical notion when a program grows large, such as a multi-million-line program. In that case, there may be internal libraries that are reused by independent sub-portions of the large program. The distinguishing feature is that a library is organized for the purposes of being reused by independent programs or sub-programs, and the user only needs to know the interface and not the internal details of the library. The value of a library lies in the reuse of standardized program elements. When a program invokes a library, it gains the behavior implemented inside that library without having to implement that behavior itself. Libraries encourage the sharing of code in a
modular Broadly speaking, modularity is the degree to which a system's components may be separated and recombined, often with the benefit of flexibility and variety in use. The concept of modularity is used primarily to reduce complexity by breaking a syst ...
fashion and ease the distribution of the code. The behavior implemented by a library can be connected to the invoking program at different
program lifecycle phase {{about, a technical topic, project management, software development process Program lifecycle phases are the stages a computer program undergoes, from initial creation to deployment and execution. The phases are edit time, compile time, link ti ...
s. If the code of the library is accessed during the build of the invoking program, then the library is called a
static library In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of Algori ...
. An alternative is to build the executable of the invoking program and distribute that, independently of the library implementation. The library behavior is connected after the executable has been invoked to be executed, either as part of the process of starting the execution, or in the middle of execution. In this case the library is called a
dynamic library In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and software ...
(loaded at runtime). A dynamic library can be loaded and linked when preparing a program for execution, by the
linker Linker or linkers may refer to: Computing * Linker (computing) In computing, a linker or link editor is a computer System software, system program that takes one or more object files (generated by a compiler or an assembler (computing), asse ...
. Alternatively, in the middle of execution, an application may explicitly request that a module be loaded. Most
compiled language A compiled language is a programming language A programming language is a formal language In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, ...
s have a
standard library A standard library in computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a specific task. Programming involves tasks such as: ...
, although programmers can also create their own custom libraries. Most modern software systems provide libraries that implement the majority of the system services. Such libraries have organized the services which a modern application requires. As such, most code used by modern applications is provided in these system libraries.


History

In 1947
Goldstine
Goldstine
and
von Neumann Von Neumann may refer to: * John von Neumann (1903–1957), a Hungarian American mathematician * Von Neumann family * Von Neumann (surname), a German surname * Von Neumann (crater), a lunar impact crater See also

* Von Neumann algebra * Von Ne ...

von Neumann
speculated that it would be useful to create a "library" of
subroutine In computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a particular task. Programming involves tasks such as analysis, generat ...
s for their work on the
IAS machine The IAS machine was the first electronic computer to be built at the Institute for Advanced Study (IAS) in Princeton, New Jersey. It is sometimes called the von Neumann machine, since the paper describing its design was edited by John von Neumann, ...
, an early computer that was not yet operational at that time. They envisioned a physical library of
magnetic wire recording Poulsen Telegraphone recorder from 1922 Wire recording or magnetic wire recording was the first magnetic recording technology, an analog signal, analog type of audio storage in which a magnetic recording is made on a thin steel wire. The first ...
s, 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 University ...
. A
filing cabinet A filing cabinet (or sometimes file cabinet in American English American English (AmE, AE, AmEng, USEng, en-US), sometimes called United States English or U.S. English, is the set of varieties of the English language native to the United S ...
of
punched tape file:PaperTapes-5and8Hole.jpg, Five- and eight-hole 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 loop P ...

punched tape
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 Computer programming is the process of designing and building an executable ...
'', which detailed the creation and the purpose of the library.
COBOL COBOL (; an acronym An acronym is a word In linguistics, a word of a spoken language can be defined as the smallest sequence of phonemes that can be uttered in isolation with semantic, objective or pragmatics, practical meaning (linguis ...

COBOL
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 Jovial may refer to: * Brice Jovial (born 1984), French football striker * JOVIAL, a programming language * Jovial High School, Yacharam, Telangana, India * Hamster Jovial, a French comic book series * The archaic adjectival form of: ** Jupiter ( ...
had 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 In computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a specific task. Programming involves tasks such as: analysis, generati ...
innovation of
FORTRAN Fortran (; formerly FORTRAN) is a general-purpose, compiled language, compiled imperative programming, imperative programming language that is especially suited to numerical analysis, numeric computation and computational science, scientific com ...

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) In computing, a linker or link editor is a computer System software, system program that takes one or more object files (generated by a compiler or an assembler (computing), asse ...
. So prior to the introduction of modules in Fortran-90,
type checking Type may refer to: Science and technology Computing * Typing Typing is the process of writing or inputting text by pressing keys on a typewriter, computer keyboard, cell phone, or calculator. It can be distinguished from other means of text inpu ...
between FORTRANIt 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 that was announced by IBM on April 7, 1964, and delivered between 1965 and 1978. It was the first family of computers designed to cover the complete range of applications, fr ...
, libraries containing other types of text elements, e.g., system parameters, also became common.
Simula Simula is the name of two simulation A simulation is the imitation of the operation of a real-world process or system over time. Simulations require the use of Conceptual model, models; the model represents the key characteristics or behavio ...
was the first
object-oriented programming Object-oriented programming (OOP) is a programming paradigm Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. Some paradigms are concerned mai ...
language, and its
classes Class or The Class may refer to: Common uses not otherwise categorized * Class (biology), a taxonomic rank * Class (knowledge representation), a collection of individuals or objects * Class (philosophy), an analytical concept used differently f ...
were nearly identical to the modern concept as used in
Java Java ( id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 147.7 million people, Java is the world's List of ...
,
C++ C++ () is a general-purpose programming language In computer software, a general-purpose programming language is a programming language dedicated to a general-purpose, designed to be used for writing software in a wide variety of application ...

C++
, and C#. The ''class'' concept of Simula was also a progenitor of the ''package'' in
Ada Ada may refer to: Places Africa * Ada Foah Ada Foah is a town on the southeast coast of Ghana, where the Volta River meets the Atlantic Ocean. The town is located along the Volta River, off of the Accra-Aflao motorway. Known for Palm tree, pal ...
and the ''module'' of
Modula-2 Modula-2 is a structured, procedural programming language A programming language is a formal language comprising a Instruction set architecture, set of instructions that produce various kinds of Input/output, output. Programming languages are ...
.Wilson and Clark, ''op. cit.'', p. 52 Even when developed originally in 1965, Simula classes could be included in library files and added at compile time.Wexelblat, ''op. cit.'', p. 716


Linking

Libraries are important in the program ''linking'' or ''binding'' process, which resolves references known as ''links'' or ''symbols'' to library modules. The linking process is usually automatically done by a ''
linker Linker or linkers may refer to: Computing * Linker (computing) In computing, a linker or link editor is a computer System software, system program that takes one or more object files (generated by a compiler or an assembler (computing), asse ...
'' or ''binder'' program that searches a set of libraries and other modules in a given order. Usually it is not considered an error if a link target can be found multiple times in a given set of libraries. Linking may be done when an executable file is created, or whenever the program is used at runtime. The references being resolved may be addresses for jumps and other routine calls. They may be in the main program, or in one module depending upon another. They are resolved into fixed or relocatable addresses (from a common base) by allocating runtime memory for the
memory segment Memory segmentation is an operating system An operating system (OS) is system software that manages computer hardware, computer software, software resources, and provides common daemon (computing), services for computer programs. Time-sharing ...
s of each module referenced. Some programming languages use a feature called ''smart linking'' whereby the linker is aware of or integrated with the compiler, such that the linker knows how external references are used, and code in a library that is never actually ''used'', even though internally referenced, can be discarded from the compiled application. For example, a program that only uses integers for arithmetic, or does no arithmetic operations at all, can exclude floating-point library routines. This smart-linking feature can lead to smaller application file sizes 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 Loader can refer to: * Loader (equipment) * Loader (computing) ** LOADER.EXE, an auto-start program loader optionally used in the startup process of Microsoft Windows ME * Loader (surname) * Fast loader * Speedloader * Boot loader ** LOADER.COM (ak ...
. 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 In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and softw ...
avoids references to absolute addresses and therefore does not require relocation.


Static libraries

When linking is performed during the creation of an executable or another object file, it is known as ''static linking'' or ''early binding''. In this case, the linking is usually done by a
linker Linker or linkers may refer to: Computing * Linker (computing) In computing, a linker or link editor is a computer System software, system program that takes one or more object files (generated by a compiler or an assembler (computing), asse ...
, but may also be done by the
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily ...

compiler
. A ''static library'', also known as an ''archive'', is one intended to be statically linked. Originally, only static libraries existed. Static linking must be performed when any modules are recompiled. All of the modules required by a program are sometimes statically linked and copied into the executable file. This process, and the resulting stand-alone file, is known as a
static build A static build is a compiled In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer ...
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 (operating systems), memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "cre ...

virtual memory
is used and no
address space layout randomization Address space layout randomization (ASLR) is a computer security technique involved in preventing exploitation of memory corruption vulnerabilities. In order to prevent an attacker from reliably jumping to, for example, a particular exploited ...
is desired.


Shared libraries

A shared library or shared object is a file that is intended to be shared by
executable files In computing, 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), instructions" ...
and further shared object files. Modules used by a program are loaded from individual shared objects into memory at
load time In computer systems A computer is a machine A machine is a man-made device that uses power to apply forces and control movement to perform an action. Machines can be driven by animals and people A people is a plurality of perso ...
or runtime, rather than being copied by a linker when it creates a single monolithic executable file for the program. Shared libraries can be statically linked during compile-time, meaning that references to the library modules are resolved and the modules are allocated memory when the executable file is created. But often linking of shared libraries is postponed until they are loaded. Most modern
operating system An operating system (OS) is system software System software is software designed to provide a platform for other software. Examples of system software include operating systems (OS) like macOS, Linux, Android (operating system), Android and Mi ...

operating system
sSome older systems, e.g.,
Burroughs MCP The MCP (Master Control Program) is the proprietary operating system An operating system (OS) is system software that manages computer hardware, computer software, software resources, and provides common daemon (computing), services for comput ...
,
Multics Multics ("Multiplexed Information and Computing Service") is an influential early time-sharing In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experi ...

Multics
, also have only a single format for executable files, regardless of whether they are shared.
can have shared library files of the same format as the executable files. This offers two main advantages: first, it requires making only one loader for both of them, rather than two (having the single loader is considered well worth its added complexity). Secondly, it allows the executables also to be used as shared libraries, if they have a
symbol table In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of Algor ...
. Typical combined executable and shared library formats are
ELF An elf (plural: ''elves'') is a type of humanoid supernatural The supernatural encompasses supposed phenomena that are not subject to the laws of nature.https://www.merriam-webster.com/dictionary/supernatural By definition, a supernat ...
and
Mach-O Mach-O, short for Mach object Object may refer to: General meanings * Object (philosophy), a thing, being, or concept ** Entity, something that is tangible and within the grasp of the senses ** Object (abstract), an object which does ...
(both in Unix) and PE (Windows). In some older environments such as 16-bit Windows or MPE for the
HP 3000 The HP 3000 series is a family of 16-bit 16-bit microcomputers are computers in which 16-bit microprocessors were the norm. A 16-bit register can store 216 different values. The range (computer programming), range of integer values that can be s ...
, only stack-based data (local) was allowed in shared-library code, or other significant restrictions were placed on shared-library code.


Memory sharing

Library code may be shared in memory by multiple
process A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic. Things called a process include: Business and management *Business process A business process, business method ...
es, as well as on disk. If virtual memory is used, processes would execute the same physical page of RAM that is mapped into the different address spaces of the processes. This has advantages. For instance, on the
OpenStep OpenStep is a defunct object-oriented application programming interface In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic ...
system, applications were often only a few hundred kilobytes in size and loaded quickly; the majority of their code was located in libraries that had already been loaded for other purposes by the operating system. Programs can accomplish RAM sharing by using
position-independent code In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and softw ...
, as in
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser Multi-user software is computer software Software is a collection of Instruction (computer science), instructions that tell a computer how to work. This is in contrast t ...

Unix
, which leads to a complex but flexible architecture, or by using common virtual addresses, as in Windows and
OS/2 OS/2 (Operating System/2) is a series of computer operating systems, initially created by Microsoft and IBM under the leadership of IBM software designer Ed Iacobucci. As a result of a feud between the two companies over how to position OS/2 re ...
. These systems make sure, by various tricks like pre-mapping the address space and reserving slots for each shared library, that code has a great probability of being shared. A third alternative is
single-level store Single-level storage (SLS) or single-level memory is a computer storage term which has had two meanings. The two meanings are related in that in both, page (computer memory), pages of memory may be in primary storage (random-access memory, RAM) or ...
, as used by the
IBM System/38 The System/38 is a discontinued minicomputer A minicomputer, or colloquially mini, is a class of smaller computers that was developed in the mid-1960s and sold for much less than mainframe and mid-size computers from IBM and its direct compe ...
and its successors. This allows position-dependent code, but places no significant restrictions on where code can be placed or how it can be shared. In some cases different versions of shared libraries can cause problems, especially when libraries of different versions have the same file name, and different applications installed on a system each require a specific version. Such a scenario is known as DLL hell, named after the Windows and OS/2 DLL file. Most modern operating systems after 2001 have clean-up methods to eliminate such situations or use application-specific "private" libraries.


Dynamic linking

Dynamic linking or
late binding Late binding, dynamic binding, or dynamic linkage—though not an identical process to dynamically linking imported code libraries—is a computer programming mechanism in which the method being called upon an object, or the function being called ...
is linking performed while a program is being loaded (
load time In computer systems A computer is a machine A machine is a man-made device that uses power to apply forces and control movement to perform an action. Machines can be driven by animals and people A people is a plurality of perso ...
) or executed ( runtime), rather than when the executable file is created. A dynamically linked library (
dynamic-link library Dynamic-link library (DLL) is Microsoft Microsoft Corporation is an American multinational Multinational may refer to: * Multinational corporation, a corporate organization operating in multiple countries * Multinational force, a militar ...
, or DLL, under
Windows Microsoft Windows, commonly referred to as Windows, is a group of several proprietary {{Short pages monitor">https://archive.today/20200114224817/https://linker.iecc.com/ 2020-01-14 -->
* Article

' by David Drysdale * Article

' by Léon Bottou and John Ryland
How to Create Program Libraries
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'06
at OOPSLA'06
How to create shared library
by Ulrich Drepper (with much background info)
Anatomy of Linux dynamic libraries
at IBM.com {{DEFAULTSORT:Library (Computing) Computer libraries, Operating system technology