Static libraries: an introduction to libraries

Let’s start with a simple question: What are libraries?

Then, what is a static library?

Let’s create our first Static Library

Compile and assemble our functions
Creating our library adding the object files
Content of our library
Content of our static library
Symbols value, type and name after using nm command
  • The “-l” option will just let the compiler to look for the prefix “lib” so it will shorter the compilation time.
  • The “-L” is to specify where we want the compiler to start looking but by using “-L.” we will let the compiler to start looking from our current directory.
Compiling a program with our library and giving the name “quote” to the executable
Executing our program with ./quote


  • It’s speed since it got all the object files inside the library (they live together) so calling functions at run-time is faster.


  • You will need to recompile your program after fixing bugs in some functions.
  • The size is larger because of the neccesity of recompile every time you add a new code to the executable.



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