Statics Libraries in C
Gastón Larroque
Commercial Assistant at WillInn | Back-end Developer | DevOps Student | Scrum | Python | FastAPI | Flask | AWS | Terraform | Docker | JavaScript | C | Linux | Office | Holberton School Alumni
When I want to play an instrument, it is first necessary to know the musical notes and to know how to play them. Once I recognize them, I’m able to?freely play music because somewhere in my mind is the information on how to play each note, even when I play different songs.
In the same way, when programming, it is very helpful to have a file where functions are stored, so I can use them in the future for different programs. That way, we avoid rewriting the functions every time they are needed.
These types of files exist in the C language and are called libraries. There are dynamic and static libraries. In this article we will focus on the static type.
Any user can create their own libraries where they can store the function prototypes they want. Therefore, each one is able to generate their own libraries and include them in the programs.
The way to include a library is through statements of the type #include or #define, words that the compiler will translate. These words go in the beginning of the program.
On UNIX static libraries are usually recognized by the suffix *.a