C Programming and Static Libraries

A vast library is a thing of beauty!

So what is a library?

The process of compiling for a C program.

Static vs. Dynamic Libraries

Making Libraries

$ gcc -c *.c
$ ar -rc libholberton.a *.o
$ ranlib libholberton.a
A peek into a C library…
nm libholberton.a

Using made libraries

  • -l<libraryname without the leading lib or the extension>
  • -L : specifies the path to the library. For the current working directory, we can use -L. If your library is not in your current directory use the path format -L/home/tmp or where ever your library is.
gcc main.c -L. -lholberton -o 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