What are libraries and why use libraries in c ?

Types of libraries in C:

Static libraries

Shared or dynamic libraries

How static libraries work

What is the difference between them

Creating A Static “C” Library

gcc -c *.c
ar -rc liball.a *.o
ranlib liball.a

How to use libraries in C


Creating A Dynamic “C” Library

gcc -c -fPIC *.c
gcc -shared -o liball.so *.o
nm -D liball.so

How to use it

gcc -L . 0-main.c -l all -o example