All you need to know about C Static libraries

Introduction

What is a library and what is it good for?

What is a static library and how does it work?

How to create static libraries?

$ gcc -c *.c
$ ar -rc libname.a *.o
$ ranlib libname.a
$ ar -rcs libname.a *.o
$ ar -t libname.a

How to use them?

$ gcc main.c -L. -lname -o main

--

--

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