Open-source tool to visualize C/C++ header file de

2019-01-21 06:32发布

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.)

4条回答
Ridiculous、
2楼-- · 2019-01-21 07:16

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.

查看更多
看我几分像从前
3楼-- · 2019-01-21 07:17

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).

查看更多
冷血范
4楼-- · 2019-01-21 07:33

Been asked many times before. always the same answer - doxygen.

查看更多
狗以群分
5楼-- · 2019-01-21 07:34

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):

apt-get install doxygen graphviz

Next, tell Doxygen to generate an initial config file that we can then modify by hand:

doxygen -g

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:

HAVE_DOT = YES
RECURSIVE = YES
EXTRACT_ALL = YES
GENERATE_LATEX = NO  # Unless you want LaTeX output besides the HTML ...

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):

PROJECT_NAME = Foobar
OUTPUT_DIRECTORY = /tmp/foobar/doc

All that remains is to tell doxygen to do its thing:

cd foobar/src
doxygen ~/Doxyfile  # Assuming you saved Doxyfile in your home directory.

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.

查看更多
登录 后发表回答