The power of a book, or how to use static libraries in C.

  1. Creating new worlds with GNU Compiler Collection.
  2. The power of a book, or how to use static libraries in C. (this article)
  3. Dynamic libraries in C: creating something on what the others will rely.

How static library works?

How to create a static library?

  1. Create the object files from the source files of the project
  2. Create the static library (the archive file) from the object files
We are required to have the project header file
The results of execution of gcc -c *.c
ar -rc libtools.a -o *.o
The results of execution of ar -rc libtools.a -o *.o
ranlib libtools.a

How to use a static library?

gcc -o resulted_program our_sources.c -L. -ltools

--

--

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
Sergii Garkusha

Sergii Garkusha

Hacker. 500 Startups Alumni. Envato Elite. School of AI Dean. Runner. Ukrainian. I write about software, AI & life. SF 🌁 https://cu7io.us