Dynamic (shared) vs. Static Library Performance

Connor Brereton
4 min readDec 11, 2018
Trinity College — Dublin, Ireland

Table of Contents:

  • What is a shared library?
  • How to create a shared library?
  • Why are they useful?
  • How is it different than a static library?

So what are they?

A shared library is a library that dynamically links during compilation when a user compiles a .c file. Static and dynamic linking are two processes of collecting and combining multiple object files in order to create a single executable file. The main difference between the two is the type of linking they do when creating an executable file.

Contrary to a static library, a dynamic library performs the linking process as a program is executed in Linux. Moreover, dynamic libraries are loaded into memory by programs when they are executed. During compilation, a shared libraries machine code is cached locally and has a version control of sorts that keeps track of what the most recent changes are to the file.

Let’s say you create a shared library and then run some tests. Next, you decide to add some more code to your functions in the shared library. Well, when you recompile, the compilation process just appends the recent changes to the cache versus having to recompile everything all over again as you would in a…

--

--