Linux 使用 make 构建后的 .d 文件是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19114410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:59:11  来源:igfitidea点击:

what is .d file after building with make

linuxbuildmakefile

提问by jaeyong

Sometimes, I find .d files for a given source file. For instance, if I compile test.c, I've got

有时,我会为给定的源文件找到 .d 文件。例如,如果我编译 test.c,我有

test.d, test.o

I understand that test.o is the object file but have no idea what is test.d for. Could you give any hints or pointers?

我知道 test.o 是目标文件,但不知道 test.d 是什么。你能给出任何提示或指示吗?

采纳答案by MadScientist

Many build systems add automatically detected make dependencies into the .dfile. In particular, for C/C++ source files they determine what #includefiles are required and automatically generate that information into the .dfile.

许多构建系统将自动检测到的 make 依赖项添加到.d文件中。特别是,对于 C/C++ 源文件,它们确定#include需要哪些文件并自动将该信息生成到.d文件中。

The .dfiles are then included by the makefile so make is aware of that information. If you look at the contents of those files they'll be make prerequisite statements, like:

.d然后这些文件包含在 makefile 中,因此 make 知道该信息。如果您查看这些文件的内容,它们将做出先决条件声明,例如:

foo.o : foo.h bar.h biz.h

etc.

等等。