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

SValakatte
2 min readJun 29, 2022

--

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 .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

--

--

SValakatte
SValakatte

Written by SValakatte

Passionate about problem solving; #VoraciousReader #MBTIEnthusiast #LovePsychology

No responses yet