Static library

From Wikipedia, the free encyclopedia

(Redirected from Static linking)
Jump to: navigation, search

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. 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 they may be loaded at run-time into the address 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 and, of course, one avoids so-called "DLL hell" in Microsoft 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 a linker or linking loader (e.g., the X11 module loader). However, whether such a process can be called static linking is controversial.

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 The C Book - Linkage and C++ linkage types for more information.

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.