Libraries, dynamic vs. static

Jorge Rodríguez
2 min readDec 15, 2020

What are libraries?

Libraries in the computer context are files that contain object files, if you need more information about the types of files created during the compilation process, you can take a look to my compilation process blog, here.

Depending on what type of library you use the size of the file is going to be affected, however both of them has their own pros and cons, this is going to be discussed on this blog.

How do they work?

The purpose of a library is to link multiple files with independent functions. So every time a function is called the code is going to be executed without needing to have all the code inside of the program source code itself.

The minimum neccesary for a static library to work are all the prototypes of the functions, and for a dynamic library we need to compile all the required files, so it can have complete access to the functions from itself.

Static libaries

This library has to be compiled during the process wich means that all the functions are append to the executable. All the information of very function containned in the library is going to be included into the final executable file.

This is very convenient since the execution will include all the functions and code within them, but the size is going to increase depending on the amount of functions within the library.

Dynamic libraries

Let’s do it!

Now that we understand the importance of the libraries in our codes, it is necessary to get step by step on how to get this to work. So first, we are going to take a look on the static libraries.

--

--

Jorge Rodríguez
0 Followers

I´m a full stack student at Holberton School, I'll write about technical genre!