
Shared libraries

Static library

Dynamic library

visibility

Static v.s Dynamic?

Dynamic libraries reduce disk space usage, as there is no need to have a copy inside each application

If a dynamic library signature or call structure changes, it can break compiled applications

You can't:

add reimplementations of virtual functions (unless it it safe for older binaries to call the original implementation), because the compiler evaluates SuperClass::virtualFunction() calls at compile-time (not link-time).

add or remove virtual member functions, because this would change the size and layout of the vtbl of every subclass.

change the type of any data members or move any data members that can be accessed via inline member functions.

add or remove private data members, because this would change the size and layout of every subclass.