当前位置:网站首页>The difference between static library and dynamic library of program
The difference between static library and dynamic library of program
2022-07-29 07:32:00 【jaky_】
Functions are code blocks that can be reused throughout the program . Using them can save time , No need to rewrite the code many times . Same as function , Libraries can also save time , Because they enable functions to be reused in multiple programs .
A static library or static link library is a set of routines , External functions and variables , They are parsed in the caller at compile time , And by the compiler , The linker or binder is copied to the target application , Thus, the object file and an independent executable file are generated . Dynamic links only include the address of the Library ( Static links are a waste of space ) Dynamic links link libraries at runtime .
Although static libraries can be reused in multiple programs , But it will be locked into the program at compile time . On the other hand , Dynamic or shared libraries exist as separate files from executable files .
The disadvantage of using a static library is that its code is locked into the final executable , It cannot be modified without recompiling . contrary , Dynamic libraries can be modified without recompiling .
Because the dynamic library is outside the executable , Therefore, the program only needs to make a copy of the library file at compile time . Using a static library means that every file in the program must have its own copy of the library file at compile time .
The disadvantage of using dynamic libraries is that programs are easier to break . for example , If the dynamic library is damaged , Then the executable may no longer work . however , Static libraries are inaccessible , Because it exists in the executable .
The benefits of using dynamic libraries are , Multiple running applications can use the same library , Instead of requiring each application to have its own copy .
Another advantage of using static libraries is the execution speed of the runtime . Because its object code ( Binary system ) Already included in the executable , So calls to multiple functions can be processed faster than dynamic library code , The code of the dynamic library needs to be called from a file other than the executable .
When to use them ?
If you have many documents , Multiple copies of the static library mean that the size of the executable file increases , Then it is recommended to use dynamic library , Can save time . If the benefits of execution time outweigh the need to save space , Then static library is the best choice .
边栏推荐
- [summer daily question] Luogu p7760 [coci2016-2017 5] tuna
- log4qt内存泄露问题,heob内存检测工具的使用
- 【暑期每日一题】洛谷 P4414 [COCI2006-2007#2] ABC
- 新生代公链再攻「不可能三角」
- 电子元器件贸易企业如何借助ERP系统,解决仓库管理难题?
- 5-整合swagger2
- Dilworth 定理
- RoBERTa:A Robustly Optimized BERT Pretraining Approach
- 如何与斯堪尼亚SCANIA建立EDI连接?
- Life cycle hooks in routing - activated and deactivated
猜你喜欢
随机推荐
[summer daily question] Luogu p1601 a+b problem (high precision)
MySQL如何把行转换为列?
美智光电IPO被终止:年营收9.26亿 何享健为实控人
js第四天流程控制(if语句和switch语句)
Summer summary (II)
gin abort不能阻止后续代码的问题
mysql 使用 DATE_FORMAT(date,'%Y-%m')
【暑期每日一题】洛谷 P4413 [COCI2006-2007#2] R2
Paper reading (62):pointer networks
Pat class a 1146 topology sequence
Scala higher order (10): exception handling in Scala
What are the answers about older bloggers?
How much data can a single MySQL table store at most?
PAT甲级 1150 旅行商问题
Use of gcc/g++
[summer daily question] Luogu p4414 [coci2006-2007 2] ABC
do end用法的妙处
Reflect reflect
Calculate program run time demo
【MYSQL】-【子查询】




![[summer daily question] Luogu p6461 [coci2006-2007 5] trik](/img/bf/c0e03f1bf477730f0b3661b3256d1d.png)




