Static Linking versus Dynamic Linking
2010-11-02 18:16
162 查看
If a copy of the libraries is physically part of the executable, then we say the executable has been statically linked.
if the executable merely contains filnames that enable the loader to find the program's library references at tuntime, then we say it has been dynamically linked.
The canonical [ 权威的,公认的] names for the three phases of collecting modules together and preparing them for execution are link-editing,loading,and runtime linking.
Statically linked modules are link edited and then loaded to run them.
Dynamically linked modules are link-edited and then loaded and runtime-linked to run them. At execution, before main() is called, the runtime loader brings the shared data objects into the process address space.It doesn't resolve external function calls until the call is actually made, so there's no penalty to linking against a library that you may not call.
The two linking methods are compared in next Figure:
Dynamic linking is the more modern approach, and has the advantage of much smaller executable size. Dynamic linking trades off more efficient use of the disk and a quicker link-edit phase for a small runtime penalty.
One purpose of Dynamic Linking Is the ABI
A major purpose of dynamic linking is to decouple programs from the particular library versions they use. Instead, we have the convention that the system provides an interface to programs, and that this interface is stable over time and successive OS releases.
Programs can call services promised by the interface, and not worry about how they are provided or how the underlying implementation may change.
Because this is an interface between application programs and the services provided by library binary executables, we call it an Application Binary Interface or ABI.
if the executable merely contains filnames that enable the loader to find the program's library references at tuntime, then we say it has been dynamically linked.
The canonical [ 权威的,公认的] names for the three phases of collecting modules together and preparing them for execution are link-editing,loading,and runtime linking.
Statically linked modules are link edited and then loaded to run them.
Dynamically linked modules are link-edited and then loaded and runtime-linked to run them. At execution, before main() is called, the runtime loader brings the shared data objects into the process address space.It doesn't resolve external function calls until the call is actually made, so there's no penalty to linking against a library that you may not call.
The two linking methods are compared in next Figure:
Dynamic linking is the more modern approach, and has the advantage of much smaller executable size. Dynamic linking trades off more efficient use of the disk and a quicker link-edit phase for a small runtime penalty.
One purpose of Dynamic Linking Is the ABI
A major purpose of dynamic linking is to decouple programs from the particular library versions they use. Instead, we have the convention that the system provides an interface to programs, and that this interface is stable over time and successive OS releases.
Programs can call services promised by the interface, and not worry about how they are provided or how the underlying implementation may change.
Because this is an interface between application programs and the services provided by library binary executables, we call it an Application Binary Interface or ABI.
相关文章推荐
- Microsoft Visual Studio ~ C/C++ Runtime Library ~ Static/dynamic linking
- Dynamic linking static library on iOS
- static linking and dynamic linking
- Static Linking vs Dynamic Linking
- Static Binding versus Dynamic Binding
- Android Static Linking vs Dynamic Linking
- static_cast 与dynamic_cast
- 总结C++中的所有强制转换函数(const_cast,reinterpret_cast,static_cast,dynamic_cast)
- static_cast、dynamic_cast 、reinterpret_cast和const_cast 四大命名转换符的说明
- c++强制类型转换:dynamic_cast、const_cast 、static_cast、reinterpret_cast
- static_cast、dynamic_cast、reinterpret_cast、和const_cast(转)
- C++中四种类型转换static_cast、const_cast、reinterpret_cast、dynamic_cast
- C++中static_cast, dynamic_cast使用方法
- C++的类型转换符:static_cast、dynamic_cast、reinterpret_cast和const_cast
- c++强制类型转换:dynamic_cast、const_cast 、static_cast、reinterpret_cast
- C++四种强制转换 static_cast , dynamic_cast , const_cast , reinterpret_cast
- static_cast、dynamic_cast reinterpret_cast和const_
- c++强制类型转换:dynamic_cast、const_cast 、static_cast、reinterpret_cast
- C++的类型转换符:static_cast、dynamic_cast、reinterpret_cast和const_cast
- static_cast、dynamic_cast、reinterpret_cast和const_cast之间的区别