- 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 atcompile-time and copied into a target application by a compiler, linker, or binder, producing anobject file and a stand-alone executable. This executable and the process of compiling it are both known as astatic build of the program. Historically, libraries could only be "static".Static libraries are either merged with other static libraries and
object file s during building/linking to form a singleexecutable , or they may be loaded atrun-time into theaddress space of the loaded executable at a static memory offset determined at compile-time/link-time.When static libraries are used to create an executable, its size will be large when compared to an executable which uses dynamic libraries. This is because linking to static libraries includes the actual code for the library function(s)/procedure(s) "with the executable", whether linked at compile-time or at run-time. However, in some cases, linking to static libraries can result in a performance improvement over linking to dynamic libraries; linking to static libraries has also been used to resolve so-called "
DLL hell " problems in older versions ofMicrosoft Windows . But these advantages are not the sole consideration, and many executables (especially those targeting Microsoft Windows) use both static and dynamic libraries.It is important to note that any static library function can call a function or procedure in another static library. The linker/linking loader/loader handles this the same way as for any "normal"
object file .Static library files may also be linked/loaded at
run-time by alinker orlinking 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" specified (e.g. not use the C "static" keyword).
See [http://publications.gbdirect.co.uk/c_book/chapter4/linkage.html The C Book - Linkage] for more information.
See also
*
Dynamic link library (.DLL)
*Library (computer science)
*Linker
*Loader (computing)
*Object file
*Prebinding
*Shared library
Wikimedia Foundation. 2010.