Come for the static library…stay for the fun

A quick introduction into the world of static libraries, how to use them, its characteristics and all that good stuff

  • Static libraries
  • Dynamic libraries, otherwise known as shared libraries

The perks of using a static library

How to use static libraries

  • the -r flag will update older files within the library
  • the -c flag will istruct ar to create the library if it doesn’t exist
  • staticlibrary is the name of the library to be created
  • file.o is the name of evert object file to be included in the static library

That’s very nice and all but…how can I use my brand new library?

  • hello.c is the program we want to compile
  • -L instructs the compiler to search for library files within this directory
  • -l(library name)
  • -o hello where “hello” is the output file name



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