Dynamic Linking and Loading
$Revision: 2.3 $
$Date: 1999/06/15 03:30:36 $
Dynamic linking defers much of the linking process until a program starts running. It provides a variety of benefits that are hard to get otherwise:
Dynamically linked shared libraries are easier to create than static linked shared libraries.
Dynamically linked shared libraries are easier to update than static linked shared libraries.
The semantics of dynamically linked shared libraries can be much closer to those of unshared libraries.
Dynamic linking permits a program to load and unload routines at runtine, a facility that can otherwise be very difficult to provide.
There are a few disadvantages, of course. The runtime performance costs of dynamic linking are substantial compared to those of static linking, since a large part of the linking process has to be redone every time a program runs. Every dynamically linked symbol used in a program has to be looked up in a symbol table and resolved. (Windows DLLs mitigate this cost somewhat, as we describe below.) Dynamic libraries are also larger than static libraries, since the dynamic ones have to include symbol tables.
Beyond issues of call compatibility, a chronic source of problems is changes in library semantics. Since dynamic shared libraries are so easy to update compared to unshared or static shared libraries, it's easy to change libraries that are in use by existing programs, which means that the behavior of those programs changes even though "nothing has changed". This is a frequent source of problems on Microsoft Windows, where programs use a lot of shared libraries, libraries go through a lot of versions, and library version control is not very sophisticated. Most programs ship with copies of all of the libraries they use, and installers often will inadvertently install an older version of a shared library on top of a newer one, breaking programs that are expecting features found in the newer one. Well-behaved applications pop up a warning before installing an older library over a newer one, but even so, programs that depend on semantics of older libraries have been known to break when newer versions replace the older ones.
Dynamic Linking and Loading
$Revision: 2.3 $
$Date: 1999/06/15 03:30:36 $
Dynamic linking defers much of the linking process until a program starts running. It provides a variety of benefits that are hard to get otherwise:
Dynamically linked shared libraries are easier to create than static linked shared libraries.
Dynamically linked shared libraries are easier to update than static linked shared libraries.
The semantics of dynamically linked shared libraries can be much closer to those of unshared libraries.
Dynamic linking permits a program to load and unload routines at runtine, a facility that can otherwise be very difficult to provide.
There are a few disadvantages, of course. The runtime performance costs of dynamic linking are substantial compared to those of static linking, since a large part of the linking process has to be redone every time a program runs. Every dynamically linked symbol used in a program has to be looked up in a symbol table and resolved. (Windows DLLs mitigate this cost somewhat, as we describe below.) Dynamic libraries are also larger than static libraries, since the dynamic ones have to include symbol tables.
Beyond issues of call compatibility, a chronic source of problems is changes in library semantics. Since dynamic shared libraries are so easy to update compared to unshared or static shared libraries, it's easy to change libraries that are in use by existing programs, which means that the behavior of those programs changes even though "nothing has changed". This is a frequent source of problems on Microsoft Windows, where programs use a lot of shared libraries, libraries go through a lot of versions, and library version control is not very sophisticated. Most programs ship with copies of all of the libraries they use, and installers often will inadvertently install an older version of a shared library on top of a newer one, breaking programs that are expecting features found in the newer one. Well-behaved applications pop up a warning before installing an older library over a newer one, but even so, programs that depend on semantics of older libraries have been known to break when newer versions replace the older ones.
การแปล กรุณารอสักครู่..
