Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The difference between dynamic link library .so and static link library .a

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Static link libraries:

  extension: .a

  compilation behavior: when compiling, the function library is integrated directly into the executor (so the document generated by compiling with static library will be larger)

The status of   independent execution: the compiled executable file can be run independently, and there is no need to read the contents of the library from the outside.

  update: if the library is updated, the entire project program needs to be recompiled

Benefits of  : convenient program migration

Dynamic link libraries:

  extension: .so

  compilation behavior: when compiling, the program only points to the indicator where the dynamic library is located, and its contents are not integrated into the execution file. Therefore, the program does not need to load all the code at the beginning of the program, and only when a function in the function library is used will the program read the contents of the dynamic library (so the documents compiled using the dynamic library will be smaller).

The state of   independent execution: the compiled executable cannot be executed independently, the function library must exist, and the directory where the library is located cannot be changed. (after moving, the link must be recompiled)

  update: if the library is updated, there is no need to recompile, because there is only the location of the library in the execution file (as long as the name and location of the library remain unchanged)

Benefits of  :

   1) keep only the interface, separate the dynamic library from the program code, improve the reusability of the code and reduce the degree of program coupling.

   2) saves memory and reduces page swapping.

For example, if the computer runs multiple programs at the same time and uses static.a, there will be multiple copies in memory. Once there are too many programs, it is possible to run out of memory.

On the other hand, in the dynamic library, there is only one copy in memory, so no space is wasted.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report