Good afternoon in this blog I am going to talk about static libraries in c, what they are, what they are for, how to create and use them.

To create a library we must write this “ar rc (here the name of a library. a ) (here all files with extension .o separated by a space each )“

For example:

ar rc test.a file1.o file2.o

Option ‘c’ tells ar to create the library if it doesn’t already exist.

The ‘r’ option tells you to replace the older object files in the library with the newer object files.

Then in order to use our library the only thing we have to do is, in the header of our program include our library as we usually do #include (name of library) and voila, we can use any function that we have pre-created in our library.

XD