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

Example:

Creating A Dynamic “C” Library

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

How to use it

export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
gcc -L . 0-main.c -l all -o example