C++ › Compilation & Linking
What is the difference between static and dynamic (shared) libraries?
AdvancedAnswer
A static library (.a/.lib) is copied into the executable at link time—larger binary, no runtime dependency, updates require relinking. A dynamic/shared library (.so/.dll) is linked at load/run time—smaller executables, shared across programs, updatable without relinking, but the library must be present at runtime and version compatibility matters. The choice trades deployment simplicity against flexibility and size.
g++ main.o -lmylib # link against libmylib (static or shared)Real-world example Shipping a plugin as a shared library lets it be updated without rebuilding the host application.