nehpets0701
1 min readOct 11, 2020

--

C Static Libraries

Static Libraries are a very useful part of the C programming language. Libraries contain many functions that are already built for you. This can be very helpful while building a program that requires many functions from a given library. You could build all of these functions yourself, but that would be time consuming and inefficient. Instead, you could include the libraries that contain these functions, and simply call them to your program.

Static Libraries can also be referred to as “archives”. They are essentially large collections of object files that contain functions. During the linking stage of compilation, these libraries are joined with the main program. Once the executable file is created, it will contain all functions from both the main program, and the libraries.

In order to make a static library, we need to turn our .c functions into object files. We can do this with the gcc -c command. The -c tells the compiler to turn turn the functions into object files after finishing the assembling phase. Once the object files are created, we can use the ar command to create the library.

--

--