[Linux Internals] My notes about : Static and Dynamic/Shared libraries

Image source: developer.ibm.com

Static libraries are compiled as part of application and Shared libraries are not.
Static linking:
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 extension.

Image Credit: Baeldung.com
Image Source: developer.ibm.com
  • 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
  1. Dynamically loaded librariesdynamically 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 librarieslinked 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

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
svalak

Passionate about problem solving; #VoraciousReader #MBTIEnthusiast #LovePsychology