Static Link Library and dynamic link library

Source: Internet
Author: User

Both static and dynamic libraries share code.

Static link library (LIB ):Complete all assembly work before the program execution and generate an executable target file (exe file ).

Static databases have two features:

    1. The executable file generated after the Link contains the code of all functions to be called, so it occupies a large disk space.
    2. If multiple (calling the same library function) processes run simultaneously in the memory, multiple identical library function codes exist in the memory, thus occupying a large amount of memory space.

Dynamic link library (DLL & Lib ):When the program loads the memory, the Library Function Code links are determined to determine their addresses. Even if several programs run simultaneously, the memory only contains one function code. The dynamic library code must meet the following conditions: it can be loaded to different addresses of different processes. Dynamic Loading can be divided into two types based on the logic address of determining the dynamic code when the program is loaded:

  • static binding: a dynamic link during loading. When a statically bound program is used to load the memory, when a program is loaded, the address of all the dynamic code called by the program is calculated and determined. This method makes the initialization time of the program just run long, but the dynamic loading is completed, the program runs quickly.
  • Dynamic binding: a dynamic link during running,The program using this method does not complete the dynamic link at the beginning, but does not calculate the Logical Address of the dynamic code until the dynamic library code is called, then, when the program needs to call another dynamic code, the loaded program calculates the logic address of this part of the code. Therefore, this method causes the program initialization time to be shorter, however, the performance during running is not as good as that of the statically bound program.

 

Static and Dynamic Link Libraries:

    1. The static Link Library loads the library before the program is executed, while the dynamic link library loads the library during the program execution.
    2. When multiple functions require the same function, the dynamic link library only needs one copy, while the static Link Library requires multiple copies.
    3. The static Link Library cannot contain other static or dynamic link libraries, and the dynamic link library can also contain other static or dynamic link libraries.
    4. If you change the library function, the program that contains the static link library needs to be relinked, but the program that contains the dynamic link library does not need to, thus greatly improving the maintainability and scalability.

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.