Dynamic Libraries in C

Why do you actually want to use a C library?

How do they work?

Create a Dynamic library

gcc *.c -c -fPIC
gcc *.o -shared -o [name_of_your_library.so]
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH

Create a Static library

gcc -Wall -pedantic -Werror -Wextra -c [the_files.c_to_include]
ar -rc [Your_library_name] [your_files]
ar -t [library_name]

How can I use a static library?

gcc [file_to_compile_]-L. -l[library] -o [created_file_name]

How can I use a Dynamic library?

gcc -Wall -pedantic -Werror -Wextra -L. [name_of_your_file.c] -[name_of_your_library] -o [final_name_of_your_compile_file]

There are differences differences between static and dynamic libraries?

PROS & CONS STATIC LIBRARIES

PROS & CONS DYNAMIC LIBRARIES

--

--

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