what is .d file after building with make

jaeyong picture jaeyong · Oct 1, 2013 · Viewed 50k times · Source

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

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?

Answer

MadScientist picture MadScientist · Oct 1, 2013

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

The .d files 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:

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

etc.