Example with four translation units:
1 2 3
|
class Base {
virtual int method() = 0;
}
| |
Neither this definition nor the implementation changes. Therefore, its object file remains valid.
1 2 3 4 5
|
#include "Base.h"
int user( Base* obj ) {
return obj->method();
}
| |
Nothing in this translation unit changes either. Therefore, its object file remains valid.
1 2 3 4 5 6
|
#include "Base.h"
class Derived : Base {
virtual int method();
// some change here
}
| |
Since definition (and implementation?) does change, this unit must recompile.
1 2 3 4 5
|
#include "Derived.h"
Base* factory() {
return new Derived;
}
| |
This unit must recompile because definition of Derived has changed.
If all of the above were in one project, then
make would not recompile the first two as long as you don't clean out the object files.
Since the non-changing object files are packaged into library, you don't clean them out and hence have no need (nor means?) to recompiled them.
Does it really matter whether the library is static or dynamically linked in this context?