Static and Shared Libraries
Build and link libraries.
What A Library Is
A library is a bundle of compiled object files you can reuse across programs without recompiling the source each time.
C has two kinds:
- Static libraries (
.a) copied into the executable at link time - Shared libraries (
.so) loaded at run time
Building Object Files
Both kinds start from object files. Compile your sources with -c as usual.
These .o files are the raw material the archiver or linker will package.
gcc -c mathlib.c -o mathlib.o
gcc -c strlib.c -o strlib.oAll lessons in this course
- Conditional Compilation
- Multi-File Projects
- Makefiles
- Static and Shared Libraries