Library (computing)

Illustration of an application which uses libvorbisfile to play an Ogg Vorbis file

In computer science, a library is a collection of read-only resources that is leveraged during software development to implement a computer program.

Historically, a library consisted of subroutines (generally called functions today). The concept now includes other forms of executable code including classes and non-executable data including images and text. It can also refer to a collection of source code.

For example, a program could use a library to indirectly make system calls instead of making those system calls directly in the program.

Characteristics

General

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 code reuse in a modular fashion.

When writing code that uses a library, a programmer only needs to know high-level information such as what items it contains at and how to use the items – not all of the internal details of the library.

Libraries can use other libraries resulting in a hierarchy of libraries in a program.

Executable

A library of executable code has a well-defined interface by which the functionality is invoked. For example, in C, a library function is invoked via C's normal function call capability. The linker generates code to call a function via the library mechanism if the function is available from a library instead of from the program itself.[1]

The functions of a library can be connected to the invoking program at different program lifecycle phases. If the code of the library is accessed during the build of the invoking program, then the library is called a static library.[2] An alternative is to build the program executable to be separate from the library file. The library functions are connected after the executable is started, either at load-time or runtime. In this case, the library is called a dynamic library.

Most compiled languages have a standard library, 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

The idea of a computer library dates back to the first computers created by Charles Babbage. 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."[3]

A woman working next to a filing cabinet containing the subroutine library on reels of punched tape for the EDSAC computer.

In 1947 Goldstine and von Neumann speculated that it would be useful to create a "library" of subroutines for their work on the IAS machine, an early computer that was not yet operational at that time.[4] They envisioned a physical library of magnetic wire recordings, with each wire storing reusable computer code.[5]

Inspired by von Neumann, Wilkes and his team constructed EDSAC. A filing cabinet of punched tape held the subroutine library for this computer.[6] Programs for EDSAC consisted of a main program and a sequence of subroutines copied from the subroutine library.[7] In 1951 the team published the first textbook on programming, The Preparation of Programs for an Electronic Digital Computer, which detailed the creation and the purpose of the library.[8]

COBOL included "primitive capabilities for a library system" in 1959,[9] but Jean Sammet described them as "inadequate library facilities" in retrospect.[10]

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. So prior to the introduction of modules in Fortran-90, type checking between FORTRAN[NB 1] subprograms was impossible.[11]

By the mid 1960s, copy and macro libraries for assemblers were common. Starting with the popularity of the IBM System/360, 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 language, Simula, developed in 1965, supported adding classes to libraries via its compiler. [12] [13]

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 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 (static linking), or whenever the program is used at runtime (dynamic linking).

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 segments 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. 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.

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, but may also be done by the compiler.[14] 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 of the program. A static build may not need any further relocation if virtual memory is used and no address space layout randomization is desired.[15]

Shared libraries

A shared library or shared object is a file that is intended to be shared by executable files and further shared object files. Modules used by a program are loaded from individual shared objects into memory at load time 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.[citation needed] But often linking of shared libraries is postponed until they are loaded.[dubiousdiscuss]

Object libraries

Although originally pioneered in the 1960s, dynamic linking did not reach the most commonly-used operating systems until the late 1980s. It was generally available in some form in most operating systems by the early 1990s. During this same period, object-oriented programming (OOP) was becoming a significant part of the programming landscape. OOP with runtime binding requires additional information that traditional libraries do not supply. In addition to the names and entry points of the code located within, they also require a list of the objects they depend on. This is a side-effect of one of OOP's core concepts, inheritance, which means that parts of the complete definition of any method may be in different places. This is more than simply listing that one library requires the services of another: in a true OOP system, the libraries themselves may not be known at compile time, and vary from system to system.

At the same time many developers worked on the idea of multi-tier programs, in which a "display" running on a desktop computer would use the services of a mainframe or minicomputer for data storage or processing. For instance, a program on a GUI-based computer would send messages to a minicomputer to return small samples of a huge dataset for display. Remote procedure calls (RPC) already handled these tasks, but there was no standard RPC system.

Soon the majority of the minicomputer and mainframe vendors instigated projects to combine the two, producing an OOP library format that could be used anywhere. Such systems were known as object libraries, or distributed objects, if they supported remote access (not all did). Microsoft's COM is an example of such a system for local use. DCOM, a modified version of COM, supports remote access.

For some time object libraries held the status of the "next big thing" in the programming world. There were a number of efforts to create systems that would run across platforms, and companies competed to try to get developers locked into their own system. Examples include IBM's System Object Model (SOM/DSOM), Sun Microsystems' Distributed Objects Everywhere (DOE), NeXT's Portable Distributed Objects (PDO), Digital's ObjectBroker, Microsoft's Component Object Model (COM/DCOM), and any number of CORBA-based systems.

Class libraries

Class libraries are the rough OOP equivalent of older types of code libraries. They contain classes, which describe characteristics and define actions (methods) that involve objects. Class libraries are used to create instances, or objects with their characteristics set to specific values. In some OOP languages, like Java, the distinction is clear, with the classes often contained in library files (like Java's JAR file format) and the instantiated objects residing only in memory (although potentially able to be made persistent in separate files). In others, like Smalltalk, the class libraries are merely the starting point for a system image that includes the entire state of the environment, classes and all instantiated objects.

Today most class libraries are stored in a package repository (such as Maven Central for Java). Client code explicitly declare the dependencies to external libraries in build configuration files (such as a Maven Pom in Java).

Remote libraries

Another library technique uses completely separate executables (often in some lightweight form) and calls them using a remote procedure call (RPC) over a network to another computer. This maximizes operating system re-use: the code needed to support the library is the same code being used to provide application support and security for every other program. Additionally, such systems do not require the library to exist on the same machine, but can forward the requests over the network.

However, such an approach means that every library call requires a considerable amount of overhead. RPC calls are much more expensive than calling a shared library that has already been loaded on the same machine. This approach is commonly used in a distributed architecture that makes heavy use of such remote calls, notably client-server systems and application servers such as Enterprise JavaBeans.

Code generation libraries

Code generation libraries are high-level APIs that can generate or transform byte code for Java. 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.[16]

File naming

Most modern Unix-like systems

The system stores libfoo.a and libfoo.so files in directories such as /lib, /usr/lib or /usr/local/lib. The filenames always start with lib, and end with a suffix of .a (archive, static library) or of .so (shared object, dynamically linked library). Some systems might have multiple names for a dynamically linked library. These names typically share the same prefix and have different suffixes indicating the version number. Most of the names are names for symbolic links to the latest version. For example, on some systems libfoo.so.2 would be the filename for the second major interface revision of the dynamically linked library libfoo. The .la files sometimes found in the library directories are libtool archives, not usable by the system as such.

macOS

The system inherits static library conventions from BSD, with the library stored in a .a file, and can use .so-style dynamically linked libraries (with the .dylib suffix instead). 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 MyFramework would be implemented in a bundle called MyFramework.framework, with MyFramework.framework/MyFramework being either the dynamically linked library file or being a symlink to the dynamically linked library file in MyFramework.framework/Versions/Current/MyFramework.

Microsoft Windows

Dynamic-link libraries usually have the suffix *.DLL,[17] although other file name extensions may identify specific-purpose dynamically linked libraries, e.g. *.OCX for OLE libraries. The interface revisions are either encoded in the file names, or abstracted away using COM-object interfaces. Depending on how they are compiled, *.LIB files can be either static libraries or representations of dynamically linkable libraries needed only during compilation, known as "import libraries". Unlike in the UNIX world, which uses different file extensions, when linking against .LIB file in Windows one must first know if it is a regular static library or an import library. In the latter case, a .DLL file must be present at runtime.

See also

Notes

  1. ^ It was possible earlier between, e.g., Ada subprograms.

References

  1. ^ Deshpande, Prasad (2013). Metamorphic Detection Using Function Call Graph Analysis (Thesis). San Jose State University Library. doi:10.31979/etd.t9xm-ahsc.
  2. ^ "Static Libraries". TLDP. Archived from the original on 2013-07-03. Retrieved 2013-10-03.
  3. ^ Babbage, H. P. (1888-09-12). "The Analytical Engine". Proceedings of the British Association. Bath.
  4. ^ Goldstine, Herman H. (2008-12-31). The Computer from Pascal to von Neumann. Princeton: Princeton University Press. doi:10.1515/9781400820139. ISBN 978-1-4008-2013-9.
  5. ^ Goldstine, Herman; von Neumann, John (1947). Planning and coding of problems for an electronic computing instrument (Report). Institute for Advanced Study. pp. 3, 21–22. OCLC 26239859. it will probably be very important to develop an extensive "library" of subroutines
  6. ^ Wilkes, M. V. (1951). "The EDSAC Computer". 1951 International Workshop on Managing Requirements Knowledge. 1951 International Workshop on Managing Requirements Knowledge. IEEE. p. 79. doi:10.1109/afips.1951.13.
  7. ^ Campbell-Kelly, Martin (September 2011). "In Praise of 'Wilkes, Wheeler, and Gill'". Communications of the ACM. 54 (9): 25–27. doi:10.1145/1995376.1995386. S2CID 20261972.
  8. ^ Wilkes, Maurice; Wheeler, David; Gill, Stanley (1951). The Preparation of Programs for an Electronic Digital Computer. Addison-Wesley. pp. 45, 80–91, 100. OCLC 641145988.
  9. ^ Wexelblat, Richard (1981). History of Programming Languages. ACM Monograph Series. New York, NY: Academic Press (A subsidiary of Harcourt Brace). p. 274. ISBN 0-12-745040-8.
  10. ^ Wexelblat, op. cit., p. 258
  11. ^ Wilson, Leslie B.; Clark, Robert G. (1988). Comparative Programming Languages. Wokingham, England: Addison-Wesley. p. 126. ISBN 0-201-18483-4.
  12. ^ Wilson and Clark, op. cit., p. 52
  13. ^ Wexelblat, op. cit., p. 716
  14. ^ Kaminsky, Dan (2008). "Chapter 3 - Portable Executable and Executable and Linking Formats". Reverse Engineering Code with IDA Pro. Elsevier. pp. 37–66. doi:10.1016/b978-1-59749-237-9.00003-x. ISBN 978-1-59749-237-9. Retrieved 2021-05-27.
  15. ^ Collberg, Christian; Hartman, John H.; Babu, Sridivya; Udupa, Sharath K. (2003). SLINKY: Static Linking Reloaded. USENIX '05. Department of Computer Science, University of Arizona. Archived from the original on 2016-03-23. Retrieved 2016-03-17.
  16. ^ "Code Generation Library". Source Forge. Archived from the original on 2010-01-12. Retrieved 2010-03-03. Byte Code Generation Library is high level API to generate and transform JAVA byte code. It is used by AOP, testing, data access frameworks to generate dynamic proxy objects and intercept field access.
  17. ^ Bresnahan, Christine; Blum, Richard (2015-04-27). LPIC-1 Linux Professional Institute Certification Study Guide: Exam 101-400 and Exam 102-400. John Wiley & Sons (published 2015). p. 82. ISBN 9781119021186. Archived from the original on 2015-09-24. Retrieved 2015-09-03. Linux shared libraries are similar to the dynamic link libraries (DLLs) of Windows. Windows DLLs are usually identified by .dll filename extensions.

Further reading

Read other articles:

San LorenzofrazioneLocalizzazioneStato Italia Regione Toscana Città metropolitana Firenze Comune Campi Bisenzio TerritorioCoordinate43°49′22.44″N 11°07′41.84″E / 43.822899°N 11.128288°E43.822899; 11.128288 (San Lorenzo)Coordinate: 43°49′22.44″N 11°07′41.84″E / 43.822899°N 11.128288°E43.822899; 11.128288 (San Lorenzo) Altitudine38 m s.l.m. Abitanti4 600[1] Altre informazioniFuso orarioUTC+1 Cart…

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Januari 2023. GameSave ManagerBerkas:Interface GameSave Manager.jpg Tampilan GameSave Manager versi 2.2 pada Windows 7GenreUtilityLisensiFreeware Sunting di Wikidata • L • B • Bantuan penggunaan templat ini GameSave Manager adalah sebuah perangkat …

Untuk bagian akhir Yeremia 25 dalam Septuaginta, lihat Yeremia 49. Yeremia 25Kitab Yeremia dalam Alkitab Ibrani, MS Sassoon 1053, foto 283-315.KitabKitab YeremiaKategoriNevi'imBagian Alkitab KristenPerjanjian LamaUrutan dalamKitab Kristen24← pasal 24 pasal 26 → Yeremia 25 (disingkat Yer 25) adalah pasal kedua puluh lima Kitab Yeremia dalam Alkitab Ibrani dan Perjanjian Lama di Alkitab Kristen. Berisi perkataan nabi Yeremia bin Hilkia, tentang Yehuda dan Yerusalem, yang hidup pada zam…

Museum SandiDidirikan29 Juli 2008 (2008-07-29)LokasiJalan Faridan M. Noto, Gondokusuman, Kota Yogyakarta, Daerah Istimewa Yogyakarta, IndonesiaKoleksiBenda-benda terkait sejarah persandian IndonesiaPemilikBadan Siber dan Sandi NegaraAkses transportasi umum 11  KotabaruSitus webbssn.go.id/museum-sandi/Mesin sandi, salah satu koleksi di dalam Museum Sandi Museum Sandi (Jawa: ꦩꦸꦱꦶꦪꦸꦩ꧀ꦱꦤ꧀ꦢꦶ, translit. Musiyum Sandi) adalah Unit Pelaksana Teknis di li…

DarlingStasiun komuter PTVLokasiClynden Avenue, Malvern EastMelbourne, VictoriaAustraliaKoordinat37°52′08″S 145°03′46″E / 37.86894°S 145.06288°E / -37.86894; 145.06288Koordinat: 37°52′08″S 145°03′46″E / 37.86894°S 145.06288°E / -37.86894; 145.06288PemilikVicTrackOperatorMetro TrainsJalur  Glen WaverleyJumlah peron2 sisiJumlah jalur2KonstruksiJenis strukturTanahParkir200Informasi lainZona tarifMyki Zona 1/2Situs web…

Ne doit pas être confondu avec Guerre civile algérienne. Guerre d'Algérie (ar) حرب الجزائر Informations générales Date 1er novembre 1954 – 5 juillet 1962[2](7 ans, 8 mois et 4 jours) Lieu AlgérieFrance Casus belli Décolonisation et guerre d'indépendance Issue Accords d'Évian Cessez-le-feu Référendum d'autodétermination Indépendance de l'Algérie Exode des pieds-noirs Changements territoriaux Fin de l'Algérie française : perte par la France des dépa…

Radio station in Madisonville, TexasKMVL-FMMadisonville, TexasFrequency100.5 MHzBrandingKMVL 100.5 FMProgrammingFormatClassic countryOwnershipOwnerLeon HuntSister stationsKMVL, KIVY, KIVY-FMHistoryCall sign meaningMadisonvilleTechnical informationFacility ID77642ClassC3ERP25,000 wattsHAAT137 m (449 ft)LinksWebsiteKMVL's website KMVL-FM is a radio station airing a classic country format licensed to Madisonville, Texas, broadcasting on 100.5 MHz FM. The station is owned by Leon Hunt…

État-major de l'Union européenneBlason de l'État-major de l'Union européenneHistoireFondation 22 janvier 2001CadreSigle EMUEType Agence de l'Union européenne, état-majorSiège Ville de BruxellesPays  BelgiqueCoordonnées 50° 50′ 44″ N, 4° 23′ 25″ EOrganisationEffectif 200Haut représentant Josep BorrellDirecteur général de l'État-major Lieutenant Général Michiel van der LaanDirecteur général adjoint Major général Giovanni ManioneAllége…

العلاقات الدومينيكية الغيانية دومينيكا غيانا   دومينيكا   غيانا تعديل مصدري - تعديل   العلاقات الدومينيكية الغيانية هي العلاقات الثنائية التي تجمع بين دومينيكا وغيانا.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عامة ومرجعية للدولتين: وجه المقا…

American judge (1834–1915) James T. MitchellChief Justice of the Supreme Court of PennsylvaniaIn office1903–1910Preceded byJ. Brewster McCollumSucceeded byD. Newlin FellJustice of the Supreme Court of PennsylvaniaIn office1889–1903 Personal detailsBorn(1834-11-09)November 9, 1834Belleville, Illinois, U.S.DiedJuly 4, 1915(1915-07-04) (aged 80)Resting placeLaurel Hill Cemetery, Philadelphia, Pennsylvania, U.S.Alma materHarvard UniversityUniversity of Pennsylvania James Tyndale Mitchell …

Politics of Egypt Member State of the African Union Member State of the Arab League Constitution (history) Government President (list) Abdel Fattah el-Sisi Prime Minister (list) Mostafa Madbouly Cabinet Mostafa Madbouly's ministry Legislature Parliament House of Representatives Speaker (list) Hanafy El Gebaly Senate Judiciary Supreme Constitutional Court Chancellor Saeed Marie Administrative divisions Governorates Subdivisions Elections Recent elections Presidential: 20182023 Parliamentary: 2020…

Пасха́льные ма́рки — почтовые марки, которые выпускают в честь Пасхи, одного из главных праздников христианского мира. Первая пасхальная почтовая марка (№ 40,  (Mi #100)) независимой Украины была напечатана Австрийской государственной типографией[de], и выпущена в 1993…

Roger ScrutonRoger Scruton en 2013.FonctionChercheurPeterhouse1969-1971BiographieNaissance 27 février 1944BuslingthorpeDécès 12 janvier 2020 (à 75 ans)BrinkworthNom de naissance Roger Vernon ScrutonNationalité britanniqueDomicile BrinkworthFormation Royal Grammar School (en) (1954-1961)Université de Cambridge (baccalauréat universitaire) (1965)Université de Cambridge (maîtrise ès arts) (1967)Université de Cambridge (doctorat) (1972)City Law School (en) (1975)City Law School (en) …

Thierry BoutsenThierry Boutsen saat pagelaran Grand Prix Inggris 1993Lahir13 Juli 1957 (umur 66)Brussels, BelgiaKarier Kejuaraan Dunia Formula SatuKebangsaan BelgiaTahun aktif1983-1993TimArrows, Benetton, Williams, Ligier dan JordanJumlah lomba164 (163 start)Juara Dunia0Menang3Podium15Total poin132Posisi pole1Lap tercepat1Lomba pertamaGrand Prix Belgia 1983Menang pertamaGrand Prix Kanada 1989Menang terakhirGrand Prix Hungaria 1990Lomba terakhirGrand Prix Belgia 1993 Thierry Marc Boutse…

Синелобый амазон Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеНадкласс:ЧетвероногиеКлада:АмниотыКлада:ЗавропсидыКласс:Птиц…

Aliran udara melalui venturi meter . Sistem kerja karburator berdasarkan Prinsip Bernoulli. Karburator[1][2][3][4] adalah perangkat komponen yang digunakan oleh mesin pembakaran dalam untuk mengontrol dan mencampur udara dan bahan bakar yang masuk ke dalam mesin. Metode utama untuk menambahkan bahan bakar ke udara masuk adalah melalui tabung Venturi berdasarkan Prinsip Bernoulli di sirkuit meteran utama, meskipun berbagai komponen lain juga digunakan untuk menyedi…

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Scatter plot – news · newspapers · books · scholar · JSTOR (April 2024) (Learn how and when to remove this template message) Plot using the dispersal of scattered dots to show the relationship between variables Not to be confused with Correlogram or Scatter matrix…

追晉陸軍二級上將趙家驤將軍个人资料出生1910年 大清河南省衛輝府汲縣逝世1958年8月23日(1958歲—08—23)(47—48歲) † 中華民國福建省金門縣国籍 中華民國政党 中國國民黨获奖 青天白日勳章(追贈)军事背景效忠 中華民國服役 國民革命軍 中華民國陸軍服役时间1924年-1958年军衔 二級上將 (追晉)部队四十七師指挥東北剿匪總司令部參謀長陸軍總…

100th season of top-tier Italian football Football league seasonSerie ASeason2001–02Dates25 August 2001 – 5 May 2002ChampionsJuventus 26th titleRelegatedHellas VeronaLecceFiorentina (to C2)VeneziaChampions LeagueJuventusRomaInternazionaleMilanUEFA CupChievoLazioParmaMatches played306Goals scored806 (2.63 per match)Top goalscorerDario HübnerDavid Trezeguet(24 goals each)Biggest home winLazio 5–0 Brescia(4 November 2001)Lazio 5–0 Perugia(20 January 2002)Piacenza 5–0 Venezia(17 Febr…

Albanian fascist paramilitary group This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Albanian Fascist Militia – news · newspapers · books · scholar · JSTOR (November 2021) (Learn how and when to remove this message) Albanian Fascist MilitiaMilicia Fashiste ShqiptareActive18 September 1939Disbanded8 September 194…

Kembali kehalaman sebelumnya