[Linux Internals] My notes about : Static and Dynamic/Shared libraries
Static libraries are compiled as part of application and Shared libraries are not.
When your application links against a static library, the library’s code becomes part of the resulting executable. This is performed only once at linking time, and these static libraries usually end with a
- Compiler translates the source program to an object module. Linker takes the object module and other modules to prepare the ‘linked module’
- Loader generates the binary memory image using the linked modules along with system libraries
- Dynamically loaded libraries — dynamically loaded and used under program control.
Dynamic loading is the technique through a program at runtime load libraries into memory, retrieve the variable/function addresses, executes the functions and unloads the program from memory. A program can have multiple modules and based on program execution, not all modules need to be present in the memory at the same time. Dynamic loading gives the capability of loading module on-demand.
2. Dynamically linked libraries — linked dynamically at run time
With Dynamic linking, here a program is linked with the shared library and the kernel loads the library (in case it’s not in memory) upon execution. i.e. linked dynamically at run time