我有3个文件
main.cpp
a.h
b.h
main.cpp 包括 a.h 和 b.h b.h包括a.h
谁能解释一下我应该如何为此编写一个 make 文件?
这是正确的吗?
objects = main.o
sources = main.cpp
myProj: $(objects)
g++ -o myProj $(objects)
main.o: a.h b.h
$(objects): $(sources)
g++ -c $(sources)
clean:
rm $(objects) myProj
我不知道如何指定b.h对a.h的依赖
最佳答案
由于 header 始终作为 .c/.cpp 文件的一部分进行编译,因此无需指定 header 到 header 的依赖性。您已经指定的依赖项就足够了,因为 main.cpp
将在 a.h 和/或 b.h 更改时重新编译。
关于c++ - 制作文件 : header including another header C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11287017/