What I'm looking for is a tool that, given a root source file, outputs a graph of file dependencies (with some customization thrown in, of course, like --maxdepth, etc.)
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
doxygen has a graph of file dependencies as one of its several outputs. It might not be exactly what you want, but it is a start.
I know it's not open source (nor linux, which you don't mention in your question but is in your tags), but I've found the best solution to this problem is ProFactor IncludeManager -- it was the best answer to a question I asked that is pretty much an exact dupe of your question, minus the open-source bit (hence why I didn't mark your question as a dupe of mine).
Been asked many times before. always the same answer - doxygen.
For the impatient, who, like me, just want a list of commands and not RTFM :) So without further ado (assuming you have Debian, or its ilk) ...
First, install Doxygen and Graphviz (which provides `dot' for drawing directed graphs):
Next, tell Doxygen to generate an initial config file that we can then modify by hand:
This will result in a new config file, called Doxyfile, generated in the current directory. You can then modify it with your favorite text editor. Make sure to set the following flags to the specified values:
You might also want to set the following two flags to tell Doxygen where to generate the documentation (which is basically just a bunch of files organized into a directory structure):
All that remains is to tell doxygen to do its thing:
Now, if you are lucky, you can point your browser at the file /tmp/foobar/doc/html/index.html, select the "Files" tab, and then click on a header file to look at two nice graphs: one shows which header files are included by your header file (directly or indirectly), while the other shows what other files include directly or indirectly the given header file.