Differences between static and dynamic libraries

Why use libraries?

How do they work? And What are the differences between static and dynamic libraries?

Static Library

Dynamic library

How to create them(Linux)?

Static Library:

gcc -Wall -pedantic -Werror -Wextra -c *.car -rc libholbertonschool.a *.o
ar -t libholbertonschool.a
/* Run */
ranlib libholbertonschool.a
gcc main.c -L. -lholbertonschool -o alpha
ranlib libholbertonschool.a

Dynamic Library:

gcc -Wall -fPIC -c *.c
gcc -shared -o liball.so *.o

How to use them(Linux)?

gcc main.c -L. -lholbertonschool -o alpha

Also before compile is important to add the localization of your library with the environmental variable to know where to find them:


What are the advantages and drawbacks of each of them?

Static linking:

Dynamic linking:

  • The size of a.out is smaller.
  • You can run several programs which the same library functions because you called it from the memory and it is more efficiently
  • We don’t need to compile the source files again if we modify any library functions
  • The executable files are not self-sufficient. It means that will always depend on the version of DLL. For example, if we change the functions in the library, maybe in the future the executable file will not compile!
executable bash to create a library with all file C typle and then use the file *.o to create de DLL
you compile your main and create your executable file with the dynamic library, then you ran your executable problem, according to the image , in this case is “./len”




Software engineer in progress

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Setting up Selenium WebDriver for Java

Devlog — Week 4

Things you need to achieve this process:

How I Made My First Unity Game in Six Hours

Open computer window with Unity game scene containing a small apartment layout from afar.

New Integrations for Vault Secrets Management and Policy-as-Code, Multi-Environment Features, and…

Code Smell 29 — Settings/Configs

How to make an animated “Wizard” component — WotW

Advice For Start Coding Journey in 2021

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
Katherine Soto

Katherine Soto

Software engineer in progress

More from Medium

Deploy your KIE Sandbox to OpenShift

Apache Flux: Frictionless STORM topology management — Part 1

Migrating applications to WebSphere Liberty — Part 1: Introduction — this is what you are reading…

Performance /Load Testing Phases