【发布时间】:2018-07-18 13:18:23
【问题描述】:
我的 makefile 中有两个 .cpp 文件:
test1.o : test1.cpp
g++ test1.cpp -o test1.o
test2.o : test2.cpp
g++ test2.cpp -o test2.o
在我对 test1.cpp 和 test2.cpp 都进行了更改并在命令行中键入 make 后,仅重新编译了 test1.o,而对 test2.o 没有任何操作。
但是,如果我交换 makefile 中的两个块,test2.o 将自动重新编译,test1.o 不会。
似乎我的 makefile 只跟踪第一个文件。我想知道哪一部分出了问题。
【问题讨论】:
-
您可能希望在这些对象上加上
-c标志,因为它们只是构建对象而不是链接。