Static library

In computer science, a static library or statically linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable.[1] This executable and the process of compiling it are both known as a static build of the program. Historically, libraries could only be static. Static libraries are either merged with other static libraries and object files during building/linking to form a single executable or loaded at run-time into the address space of their corresponding executable at a static memory offset determined at compile-time/link-time.

Advantages and disadvantages

There are several advantages to statically linking libraries with an executable instead of dynamically linking them. The most significant advantage is that the application can be certain that all its libraries are present and that they are the correct version. This avoids dependency problems, known colloquially as DLL Hell or more generally dependency hell. Static linking can also allow the application to be contained in a single executable file, simplifying distribution and installation.

With static linking, it is enough to include those parts of the library that are directly and indirectly referenced by the target executable (or target library). With dynamic libraries, the entire library is loaded, as it is not known in advance which functions will be invoked by applications. Whether this advantage is significant in practice depends on the structure of the library.

In static linking, the size of the executable becomes greater than in dynamic linking, as the library code is stored within the executable rather than in separate files. But if library files are counted as part of the application then the total size will be similar, or even smaller if the compiler eliminates the unused symbols.

Environment specific

On Microsoft Windows it is common to include the library files an application needs with the application.[2] On Unix-like systems this is less common as package management systems can be used to ensure the correct library files are available. This allows the library files to be shared between many applications leading to space savings. It also allows the library to be updated to fix bugs and security flaws without updating the applications that use the library. In practice, many executables (especially those targeting Microsoft Windows) use both static and dynamic libraries.

Linking and loading

Any static library function can call a function or procedure in another static library. The linker and loader handle this the same way as for kinds of other object files. Static library files may be linked at run time by a linking loader (e.g., the X11 module loader). However, whether such a process can be called static linking is controversial.

Creating static libraries in C/C++

Static libraries can be easily created in C or in C++. These two languages provide storage-class specifiers for indicating external or internal linkage, in addition to providing other features. To create such a library, the exported functions/procedures and other objects variables must be specified for external linkage (i.e. by not using the C static keyword). Static library filenames usually have ".a" extension on Unix-like systems[1] and ".lib" extension on Microsoft Windows.

For example, on a Unix-like system, to create an archive named libclass.a from files class1.o, class2.o, class3.o, the following command would be used:[1]

ar rcs libclass.a class1.o class2.o class3.o

to compile a program that depends on class1.o, class2.o, and class3.o, one could do:

cc main.c libclass.a

or (if libclass.a is placed in standard library path, like /usr/local/lib)

cc main.c -lclass

or (during linking)

ld ... main.o -lclass ...

instead of:

cc main.c class1.o class2.o class3.o

See also

References

  1. ^ a b c "Static Libraries". TLDP. Retrieved 3 October 2013.
  2. ^ Anderson, Rick (2000-01-11). "The End of DLL Hell". microsoft.com. Archived from the original on 2001-06-05. Retrieved 2013-08-31. Private DLLs are DLLs that are installed with a specific application and used only by that application.

Read other articles:

Beautiful WorldAlbum studio karya ArashiDirilis06 Juli 2011 (2011-07-06)Direkam2010-2011GenrePop, R&BDurasi75:31[1]LabelJ StormKronologi Arashi Boku no Miteiru Fūkei(2010)String Module Error: Match not found2010 Beautiful World(2011) Ura Ara Mania(2012)String Module Error: Match not found2012 Singel dalam album Beautiful World To Be FreeDirilis: 07 Juli 2010 (2010-07-07) Love RainbowDirilis: 08 September 2010 (2010-09-08) Dear SnowDirilis: 21 Oktober 2010 ...

 

 

Untuk drama Beaumarchais, lihat Pernikahan Figaro (drama). Untuk opera karya Marcos Portugal (1799), lihat Marcos Portugal. Le nozze di FigaroPernikahan FigaroOpera karya W. A. MozartEngravir awal abad ke-19 yang menggambarkan Count Almaviva dan Susanna pada bagian 3LibrettistLorenzo Da PonteBahasaItaliaBerdasarkan padaLe Mariage de Figarooleh Pierre BeaumarchaisPenampilan perdana01 Mei 1786 (1786-05-01)Burgtheater, Wina Pernikahan Figaro (bahasa Italia: Le nozze di Figaro, diucapkan...

 

 

Hyperboloïde de révolution à une nappe En mathématiques, la géométrie dans l'espace consiste à étudier les objets définis dans la géométrie plane dans un espace à trois dimensions et à y ajouter des objets qui ne sont pas contenus dans des plans : surfaces (plans et surfaces courbes) et volumes fermés. Il s'agit donc de géométrie dans un espace à trois dimensions. Géométrie euclidienne dans l'espace On peut adopter, dans l'espace à trois dimensions, les mêmes axiomes...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (يونيو 2019) إيواو أكياما (باليابانية: 秋山巌)‏  معلومات شخصية الميلاد 21 مارس 1921  تاكيتا، أويتا  الوفاة 15 سبتمبر 2014 (93 سنة)   ماتسودو، تشيبا  مواطنة اليابان  ال

 

 

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (أغسطس 2018) عبد الرزاق أبو بكر معلومات شخصية تاريخ الميلاد 27 ديسمبر 1962 (العمر 60 سنة) الطول 168 سنتيمتر[1]  الجنسية مالديفي الوزن 59 كيلوغرام[1]  الحياة العملية ا...

 

 

Ehemaliger Kanton Marseille-Vauban Region Provence-Alpes-Côte d’Azur Département Bouches-du-Rhône Arrondissement Marseille Auflösungsdatum 29. März 2015 Einwohner 31.148 (1. Jan. 2012) Bevölkerungsdichte 17.698 Einw./km² Fläche 1.76 km² Gemeinden 1 INSEE-Code 1359 Der Kanton Marseille-Vauban war bis 2015 ein französischer Wahlkreis im Arrondissement Marseille, im Département Bouches-du-Rhône und in der Region Provence-Alpes-Côte d’Azur. Die landesweiten Ä...

Біг на 400 метрів з бар'єрами (жінки)на Чемпіонаті світу з легкої атлетики 2022Місце Гейворд ФілдУчасників 37 з 26 країнРозкладЗабіги 19 липняПівфінали 20 липняФінал 22 липняПризери01 ! Сідні Мак-Лафлін02 ! Фемке Бол3 ! Далайла Мухаммад← 2019 2023 → Чемпіонат світу з легкої ат

 

 

Sitio de Gaza Guerras de Alejandro MagnoParte de guerras de Alejandro Magno Cuadro de Gaza (David Roberts).Fecha 332 a. C.Lugar Gaza, (actual Franja de Gaza)Coordenadas 31°31′00″N 34°27′00″E / 31.516667, 34.45Resultado Victoria macedonia[1]​Beligerantes Reino de Macedonia Liga Helénica  Imperio aqueménidaCiudadanos de Gaza Mercenarios árabes[2]​ Comandantes Alejandro Magno Batis  (P.D.G.)  Fuerzas en combate 45,000 15,000[1]...

 

 

شارل لوسيان بونابرت (بالفرنسية: Charles Lucien Jules Laurent Bonaparte)‏، و(بالفرنسية: Charles Lucien Bonaparte)‏    معلومات شخصية اسم الولادة (بالفرنسية: Charles Lucien Jules Laurent Bonaparte)‏  الميلاد 24 مايو 1803[1][2]  باريس[3][4]  الوفاة 29 يوليو 1857 (54 سنة) [1][2]  باريس[4]  مكان ال

Egao Yes NudeSingel oleh Morning Musumedari album Sexy 8 BeatSisi-BSayonara no Kawari niDirilis14 Februari 2007 (2007-02-14)FormatCD, DVDDirekam2007GenrePopLabelZetimaPenciptaTsunkuProduserTsunkuVideo musikEgao Yes Nude di YouTube Egao Yes Nude (笑顔Yesヌードcode: ja is deprecated ) adalah single ketiga puluh dua Morning Musume. Singel ini dirilis pada tanggal 14 Februari 2007, pada awalnya diisukan menjadi singel terakhir Hitomi Yoshizawa namun hal ini dibantah. Singel Ini adalah y...

 

 

قرية أبا ذينة  - قرية -  تقسيم إداري البلد  اليمن المحافظة محافظة البيضاء المديرية مديرية الشرية العزلة عزلة آل غنيم السكان التعداد السكاني 2004 السكان 136   • الذكور 82   • الإناث 54   • عدد الأسر 15   • عدد المساكن 15 معلومات أخرى التوقيت توقيت اليمن (+3 غريني...

 

 

Type of harness for sexual intercourse 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: Sex swing – news · newspapers · books · scholar · JSTOR (February 2020) (Learn how and when to remove this template message) A sex swing A sex swing (also known as a sling) is a type of harness designed to allow sexual int...

Town in New South Wales, AustraliaVallaNew South WalesSouth Valla Beach, 2023VallaCoordinates30°36′S 152°59′E / 30.600°S 152.983°E / -30.600; 152.983Population1,054 (2006 census)[1]Postcode(s)2448Location 7 km (4 mi) north of Nambucca Heads 33 km (21 mi) south of Coffs Harbour LGA(s)Nambucca Valley CouncilState electorate(s)OxleyFederal division(s)Cowper Valla is a suburb in the Nambucca Valley, on the Mid North Coast of New Sou...

 

 

Ethnic group in Switzerland Turks in SwitzerlandTotal population120,000 (2009 estimate)[1]Regions with significant populationsZurichBaselLausanneLanguagesTurkishFrenchGermanItalianReligionPredominantly Sunni Islam Minority Alevism, Christianity, Other religions, or Irreligious Turks in Switzerland (Turkish: İsviçre'deki Türkler), also referred to as Swiss Turks (Turkish: İsviçreli Türkler) and Turkish Swiss people (Turkish: Türk İsviçreliler), are Swiss residents of Turkish o...

 

 

In this Spanish name, the first or paternal surname is Chacón and the second or maternal family name is Rodríguez. Venezuelan baseball player (1936-1992) Baseball player Elio ChacónSecond basemanBorn: (1936-10-26)October 26, 1936Caracas, VenezuelaDied: April 24, 1992(1992-04-24) (aged 55)Caracas, VenezuelaBatted: RightThrew: RightMLB debutApril 20, 1960, for the Cincinnati RedsLast MLB appearanceSeptember 30, 1962, for the New York MetsMLB statist...

Cities of the Holy Roman Empire with self-rule and representation in the Imperial Diet Imperial city and Reichsstadt redirect here. For other uses and similar terms, see Imperial City (disambiguation) and Reichstadt (disambiguation). You can help expand this article with text translated from the corresponding article in German. (April 2018) Click [show] for important translation instructions. Machine translation, like DeepL or Google Translate, is a useful starting point for translations...

 

 

Indian actress Mahua Roy Choudhuryমহুয়া রায় চৌধুরীRoy Choudhury in Dadar Kirti (1980)Born(1958-09-24)24 September 1958[1]Died22 July 1985(1985-07-22) (aged 26)Calcutta, West BengalOccupationActressYears active1973–1985Known forShriman PrithvirajDadar KirtiAaj Kal Parshur GalpoAadmi Aur AuratRajpurush Mahua Roy Choudhury (Bengali: মহুয়া রায় চৌধুরী; 24 September 1958 – 22 July 1985) was an Indian actr...

 

 

Species of mushroom Gymnopilus fulgens Gymnopilus fulgens in NSG Heiliges Meer, Recke, Nordrhein-Westfalen, Germany Scientific classification Domain: Eukaryota Kingdom: Fungi Division: Basidiomycota Class: Agaricomycetes Order: Agaricales Family: Hymenogastraceae Genus: Gymnopilus Species: G. fulgens Binomial name Gymnopilus fulgens(J. Favre & Maire) Singer Species of fungus Gymnopilus fulgensMycological characteristicsGills on hymeniumCap is convex Hymenium is adnexed or adnateEcolo...

(Titik menunjukkan kota, dapat diklik)■ ― Kota terpilih■ ― Kota inti■ ― Kota khusus Kota Istimewa (特例市 (とくれいし) Tokureishi) Jepang adalah kota-kota yang mempunyai jumlah populasi penduduk sekitar 200,000 orang dan berfungsi untuk menjalankan peranan kepada pemerintah kota seperti yang telah ditetapkan oleh kota inti. Kategori ini telah dibentuk oleh Undang-undang Otonomi Daerah, Pasal 252 ayat 26. Di mana isinya telah ditetapkan oleh Badan Kabinet Jepang seperti y...

 

 

Austrian cyclist Georg TotschnigPersonal informationFull nameGeorg TotschnigBorn (1971-05-25) 25 May 1971 (age 52)Kaltenbach, AustriaHeight1.75 m (5 ft 9 in)Weight62 kg (137 lb; 9 st 11 lb)Team informationCurrent teamRetiredDisciplineRoadRoleRiderRider typeClimbing specialistProfessional teams1993Lampre – Polti1994Polti1995Polti – Granarolo – Santini1996Polti1997–2000Deutsche Telekom2001–2006Gerolsteiner Major winsTour d...

 

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!