# static library and dynamic linked library ## This example demonstrate the usage of static libraries: run with: ```sh gcc -c add_vec.c mul_vec.c ar rcs libvec.a add_vec.o mul_vec.o gcc -c main.c gcc -static -o prog2c.bin main.o ./libvec.a ./prog2c.bin ``` ## Run with dynamic linked library: ```sh gcc -shared -fpic -o libvec.so add_vec.c mul_vec.c gcc -o prog21.bin main.c ./libvec.so ``` We see `prog2c` is 764 KB while `prog21` is 20 KB. ```sh ✔≻ lsd -l prog21.bin .rwxr-xr-x vitalyr eva 20 KB Wed Nov 2 14:05:44 2022  prog21 ✔≻ lsd -l prog2c.bin .rwxr-xr-x vitalyr eva 764 KB Mon Oct 31 01:38:55 2022  prog2c ```