Lets say i have the following program, separated into different files and representing basic linear algebra elements in 3d space
point3D.hpp
vector3D.hpp
line3D.hpp
#include vector3D.hpp
main.cpp
#include "point3D.hpp" #include "line3D.hpp"
and i want to create a makefile for them, which dependencies do I have to consider?
So it is obvious that main.cpp directly depends on point3D.hpp and line3D.hpp and indirectly depends on "vector3d.hpp".
But what does that mean for compilation? Let's say I modified the file vector3D.hpp, i obviously have to recompile vector3D.cpp getting vector3D.o (not in that list).
But do I also have to recompile line3D.cpp -> line3D.o and main.cpp -> main.o then because they directly & indirectly depend on vektor3D.hpp, or is it sufficient just to link object files again to a new executable?
And if it varies from case to case, when is it necessary to recompile all dependent files & when is it sufficient to compile & relink the modified file.
And what is the best way to implement that correctly into a makefile?
I tried to learn more about linking & compiling in c++, but was not able to find one sufficient page which could answer my question.