Svoboda | Graniru | BBC Russia | Golosameriki | Facebook

To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

Static library

From Wikipedia, the free encyclopedia

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.

YouTube Encyclopedic

  • 1/3
    Views:
    39 675
    7 942
    2 393
  • What is difference between Dynamic and Static library(Static and Dynamic linking)
  • Using Libraries in C++ (Static Linking)
  • How to create Static library and Use it in Linux : Advanced Linux Programming # Tutorial - 3

Transcription

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.
This page was last edited on 21 February 2024, at 15:22
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.