c++ - 在哪些情况下我应该在 Makefile 中保留多个目标而不是一个目标?

标签 c++ linux makefile terminology

targetOne : header/headerAB.h source/sourceA.cpp source/sourceB.cpp source/main.cpp
         g++ -Wall header/headerAB.h source/sourceA.cpp source/sourceB.cpp source/main.cpp

为什么我应该在多个目标中打破它而不是将它保持为一个?
在什么情况下我们需要有单独的目标而不是 Makefile 中的目标?

最佳答案

引用 http://mrbook.org/tutorials/make/

Using dependencies. Sometimes is useful to use different targets. This is because if you modify a single file in your project, you don't have to recompile everything, only what you modified.

因此在部分源更新后您将获得更快的重新编译。对于大型项目来说,这是“必须实现的”,其中任何更改都非常小(与整个 > 1M LOC 项目相比)。

此外,多个目标允许您为项目的不同部分设置不同的规则。

关于c++ - 在哪些情况下我应该在 Makefile 中保留多个目标而不是一个目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11293301/

相关文章:

c++ - 如何使用 libssh 运行 makefile?

makefile - mt19937 不是 std 的成员 可能的 makefile 问题

c++ - 您如何才能准确地看到内存泄漏的内容?

c++ - 在 ANTLR 生成的 C 解析器中使用 C++ 类型

linux - 考虑动态流量的 PCAP 管理解决方案?

linux - Linux C++ IDE 中的解决方案文件相当于什么

c++ - 作者基于 union 的可选 <bool> 实现在 P2641 中定义良好吗?

c++ - 优化处理标签(空结构)函数参数

linux - 在 linux 中安装 java 问题

linux - 以下Makefile行的效果是?