Libraries in C: static or dynamic?

Photo by Evgeni Tcherkasski on Unsplash

What is a library in C?

Why choose one over the other?

Static library
Dynamic (or shared) library
Benchmark

How to create a Static library?

How to create a Dynamic / Shared library?

ldd len 
linux-vdso.so.1 => (0x00007fff5d1d2000)
libholberton.so => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f74c6bb9000)
/lib64/ld-linux-x86-64.so.2 (0x0000556be5b82000)
$ export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
ldd len
linux-vdso.so.1 => (0x00007fff41ae9000)
libholberton.so => ./libholberton.so (0x00007fd4bf2d9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd4beef6000)
/lib64/ld-linux-x86-64.so.2 (0x0000557566402000)

How to use a static or dynamic library?

gcc -L. *.c -lname -o out

Software Engineer student at Holberton School. Reach me @huyxuanminh