In computer science, a library is a collection of subroutines or classes used to develop software. Libraries contain code and data that provide services to independent programs. This allows the sharing and changing of code and data in a modular fashion. Some executables are both standalone programs and libraries, but most libraries are not executables. Executables and libraries make references known as links to each other through the process known as linking , which is typically done by a linker.

As of 2009, most modern software systems provide libraries that implement the majority of system services. Such libraries have commoditized the services which a modern application requires. As such, most code used by modern applications is provided in these system libraries.

History

The earliest programming concepts analogous to libraries were intended to separate data definitions from the program implementation. JOVIAL brought the "COMPOOL" (Communication Pool) concept to popular attention in 1959, although it adopted the idea from the large-system SAGE software. Following the computer science principles of separation of concerns and information hiding, "Comm Pool's purpose was to permit the sharing of System Data among many programs by providing a centralized data description."(Wexelblat 1981:369

COBOL also included "primitive capabilities for a library system" in 1959 (Wexelblat 1981:274), but Jean Sammet described them as "inadequate library facilities" in retrospect. (Wexelblat 1981:258)

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 lacks a linker, so type checking between subprograms is impossible. (Wilson et al. 1988:126)

Finally, historians of the concept should remember the influential Simula 67. Simula was the first object-oriented programming language, and its classes are nearly identical to the modern concept as used in Java, C++, and C#. The class concept of Simula was also a progenitor of the package in Ada and the module of Modula-2. (Wilson et al. 1988:52) Even when developed originally in 1965, Simula classes could be included in library files and added at compile time. (Wexelblat 1981:716)

Types

Static libraries

Main article: Static Library

Originally, only static libraries existed. A static library, also known as an archive , consists of a set of routines which are copied into a target application by the compiler, linker, or binder, producing object files and a stand-alone executable file. This process, and the stand-alone executable file, are known as a static build of the target application. Actual addresses for jumps and other routine calls are stored in a relative or symbolic form which cannot be resolved until all code and libraries are assigned final static addresses.

The linker resolves all of the unresolved addresses into fixed or relocatable addresses (from a common base) by loading all code and libraries into actual runtime memory locations. This linking process can take as much, or more, time than the compilation process, and must be performed when any of the modules is recompiled. Most compiled languages have a standard library, but programmers can also create their own custom libraries. Commercial compiler publishers provide both standard and custom libraries with their compiler products.

A linker may work on specific types of object files, and thus require specific (compatible) types of libraries. Collecting object files into a static library may ease their distribution and encourage their use. A client, either a program or a library subroutine, accesses a library object by referencing just its name . The linking process resolves references by searching the libraries in the order given. Usually, it is not considered an error if a name can be found multiple times in a given set of libraries.

Some programming languages may use a feature called "smart linking" where 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 deleted from the compiled application. For example, a program that only uses integers for arithmetic, or does no arithmetic operations at all, can exclude the floating-point library routines. This smart-linking feature can lead to smaller application file sizes and reduced memory usage.

Dynamic linking

Dynamic linking involves loading the subroutines of a library into an application program at runtime, rather than linking them in at compile time; the subroutines remain as separate files on disk. Only a minimum amount of work is done at compile time by the linker; it only records what library routines the program needs and the index names or numbers of the routines in the library. The majority of the work of linking is done at the time the application is loaded (loadtime) or during execution (runtime). The necessary linking code, called a loader, is actually part of the underlying operating system. At the appropriate time the loader finds the relevant libraries on disk and adds the relevant data from the libraries to the process's memory space.

Some operating systems can only link in a library at loadtime, before the process starts executing; others can wait until after the process has started to execute and link in the library just when it is actually referenced (i.e., during runtime). The latter is often called "delay loading" or "deferred loading". In either case, such a library is called a dynamically linked library.

The nature of dynamic linking makes it a common place beyond which someone who grants a software license may choose to not enforce further terms. For example, the GPL linking exception allows programs to use libraries available under GPL licenses without themselves becoming subject to the full terms of the GPL as a result.

Plugins exemplify one common usage of dynamically linked libraries, which is especially useful when the libraries can be replaced by other libraries with a similar interface, but different functionality. Software may be said to have a "plugin architecture" if it uses libraries for core functionality with the intention that they can be replaced. Note, however, that the use of dynamically linked libraries in an application's architecture does not necessarily mean that they may be replaced.

Programmers originally developed dynamic linking in the Multics operating system, starting in 1964. It was also a feature of MTS (the Michigan Terminal System), built in the late 1960s. In Microsoft Windows, dynamically-linked libraries are called dynamic-link libraries or "DLLs".

Relocation

Main article: Relocation (computer science)

The loader must solve one problem: the actual location in memory of the library data cannot be known until after the executable and all dynamically linked libraries have been loaded into memory. This is because the memory locations used depend on which specific dynamic libraries have been loaded. It is not possible to depend on the absolute location of the data in the executable, nor even in the library, since conflicts between different libraries would result: if two of them specified the same or overlapping addresses, it would be impossible to use both in the same program.

However, in practice, the shared libraries on most systems do not change often. Therefore, systems can compute a likely load address for each shared library on the system before it is needed, and store that information in the libraries and executables. If every shared library that is loaded has undergone this process, then each will load at their predetermined addresses, which speeds up the process of dynamic linking. This optimization is known as prebinding in Mac OS X and prelinking in Linux. Disadvantages of this technique include the time required to precompute these addresses every time the shared libraries change, the inability to use address space layout randomization, and the requirement of sufficient virtual address space for use (a problem that will be alleviated by the adoption of 64-bit architectures, at least for the time being).

The library itself contains a jump table of all the methods within it, known as entry points . Calls into the library "jump through" this table, looking up the location of the code in memory, then calling it. This introduces overhead in calling into the library, but such a small delay as to be negligible.

Locating libraries at runtime

Main article: Dynamic linker

Dynamic linkers/loaders vary widely in functionality. Some depend on the executable storing explicit paths to the libraries. Any change to the library naming or layout of the filesystem will cause these systems to fail. More commonly, only the name of the library (and not the path) is stored in the executable, with the operating system supplying a system to find the library on-disk based on some algorithm.

One of the biggest disadvantages of dynamic linking involves the executables depending on the separately stored libraries in order to function properly. If the library is deleted, moved, or renamed, or if an incompatible version of the DLL is copied to a place

Deakin Software Library

Deakin Software Library; a repository of software downloads for Deakin University staff and students, and the general public.

...

Net Services Software Library

The Net Services Software Library These download links are to the full version of the evaluation or freeware editions. Check the Details link for compatibility issues, patch ...

...

ZDNet Software Library

ZDNet's Software Directory is the Web's largest library of software downloads. Covering software for Windows, Mac, and Mobile systems, ZDNet's Software Directory is the best source ...

...

Software Library :: RED LION CONTROLS ::

:: Software Library :: Download the latest version of RLC Configuration Software for our HMI’s, Modular Controller Series, Temperature Controllers, Panel Meters, and Message ...

...

Library (computing) - Wikipedia, the free encyclopedia

In computer science, a library is a collection of subroutines or classes used to develop software. Libraries contain code and data that provide services to independent programs.

...

Cyberwalker Software Library - Home

A software library that offers downloadable freeware, payware and shareware.

...

AFSFITS Software Library

Software Library Listing FISHERIES PROGRAMS FOR IBM-PC's AND COMPATIBLES - These programs are available from the Fisheries Information and Technology Section.

...

Software Library & Resources | Yale ITS

Information Technology Services (ITS) provides computing and communications infrastructure, services, support, and innovation for Yale's instructional, research, public service ...

...

Sun Software Library Overview Screencast - Sun Software Library ...

Bob May on the Sun Software Library team put together this overview screencast, demonstrating how to search and publish using the Sun Software Libray.

...

Software library - What does SL stand for? Acronyms and abbreviations ...

RAIDn data protection technology is a software library with a set of patented algorithms that implement a parity scheme across an array of disk drives, providing data protection ...

...