Dynamic link library and static link library

Source: Internet
Author: User

Dynamic Link Library Concepts

Dynamic Library (Abbr,dll) technology is a technique commonly used in programming. Its purpose is to reduce the size of the program, save space, improve efficiency, with high flexibility. Using dynamic library technology makes it easier to upgrade software versions. Unlike a static library, a function inside a dynamic library is not part of the execution program itself , but is loaded on demand as execution requires, and its execution code can be shared among multiple programs at the same time.

Under Linux, dynamic-link libraries exist with. So suffixes! Under Windows, dynamic-link libraries exist with the suffix. dll.

Advantages

The dynamic link library is not part of the execution program itself, but is based on the need to load the execution program, while its execution code can be shared among multiple executing programs, saving space, improving efficiency, high flexibility, and being favored by more and more programmers and users. It is suitable for large-scale software development, makes the development process independent, the coupling degree is small, facilitates the development and the test between different developers and the development organization.

A. Sharing: Multiple applications can use the same dynamic library, when launching multiple applications, only need to load the dynamic library into memory once;
B. Development module good: requires the designer to divide the function better.

Disadvantages

A program that uses a dynamic-link library must deploy a dynamic-link library to the appropriate environment, and if the dynamic library does not exist, the program will inevitably get an error! Second, the program loads more slowly than static links. When a module is updated, if the new module is incompatible with the old module, then the software that needs the module to run is torn away. This is common in early windows.

Issues such as reference counting cannot be resolved.

Static link Library Concepts

Under Linux, the static library exists with the suffix name of. A, and under Windows, the static library exists with the suffix name of. lib!

The code in the library eventually needs to be connected to your executable file, so the statically connected executables are generally a bit larger.

Advantages

The code is loaded faster and executes slightly faster than a dynamic-link library, just to be sure that it is correct on the developer's computer. LIB/.A file, and then publish the program in binary form without consideration on the user's computer. LIB file exists and version problem, can avoid DLL hell and so on.

Disadvantages

Executables generated using static links are large and contain the same common code, resulting in waste, but if multiple applications are used, they are loaded multiple times, wasting memory.

The difference between the two

The difference between the two is that the code is loaded in a different time.

The code for the static library has been loaded into the executable program during compilation, so the volume is large.
The code for a dynamic shared library is loaded into memory when the executable is running, only a simple reference during compilation, so the code is small.

Dynamic link library and static link library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.