可视化C/ c++头文件依赖项的开源工具?

时间:2021-08-13 15:06:04

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

我所寻找的是一个工具,给定一个根源文件,输出一个文件依赖关系图(当然,还有一些定制,比如maxdepth等)。

4 个解决方案

#1


45  

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

对于那些没有耐心的人,像我一样,他们只想要一个命令列表,而不是RTFM:)所以,不要再多说了(假设你有Debian,或者它的ilk)……

First, install Doxygen and Graphviz (which provides `dot' for drawing directed graphs):

首先,安装Doxygen和Graphviz(为绘制有向图提供“点”):

apt-get install doxygen graphviz

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

接下来,告诉Doxygen生成一个初始配置文件,然后我们可以手动修改:

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:

这将导致在当前目录中生成一个名为Doxyfile的新配置文件。然后可以用您喜欢的文本编辑器修改它。确保将下列标志设置为指定的值:

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

您可能还需要设置以下两个标志,告诉Doxygen在哪里生成文档(基本上只是将一堆文件组织成一个目录结构):

PROJECT_NAME = Foobar
OUTPUT_DIRECTORY = /tmp/foobar/doc

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

剩下的就是告诉doxygen做它的事情:

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.

现在,如果幸运的话,可以将浏览器指向文件/tmp/foobar/doc/html/索引。html,选择“Files”选项卡,然后单击一个头文件,查看两个漂亮的图:一个显示头文件包含哪个头文件(直接或间接),而另一个显示其他文件包括直接或间接的给定头文件。

#2


4  

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.

doxygen有一个文件依赖关系图作为它的几个输出之一。这可能不是你想要的,但却是个开始。

#3


1  

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

我知道这不是开源(或linux,你别提你的问题,但在你的标签),但我发现这个问题的最佳解决方案是ProFactor IncludeManager——这是最好的回答一个问题几乎完全欺骗的我问你的问题,-开源位(因此为什么我没有你的问题标记为一个欺骗我的)。

#4


0  

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

以前被问过很多次。一直都是同一个答案——多氧基。

#1


45  

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

对于那些没有耐心的人,像我一样,他们只想要一个命令列表,而不是RTFM:)所以,不要再多说了(假设你有Debian,或者它的ilk)……

First, install Doxygen and Graphviz (which provides `dot' for drawing directed graphs):

首先,安装Doxygen和Graphviz(为绘制有向图提供“点”):

apt-get install doxygen graphviz

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

接下来,告诉Doxygen生成一个初始配置文件,然后我们可以手动修改:

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:

这将导致在当前目录中生成一个名为Doxyfile的新配置文件。然后可以用您喜欢的文本编辑器修改它。确保将下列标志设置为指定的值:

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

您可能还需要设置以下两个标志,告诉Doxygen在哪里生成文档(基本上只是将一堆文件组织成一个目录结构):

PROJECT_NAME = Foobar
OUTPUT_DIRECTORY = /tmp/foobar/doc

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

剩下的就是告诉doxygen做它的事情:

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.

现在,如果幸运的话,可以将浏览器指向文件/tmp/foobar/doc/html/索引。html,选择“Files”选项卡,然后单击一个头文件,查看两个漂亮的图:一个显示头文件包含哪个头文件(直接或间接),而另一个显示其他文件包括直接或间接的给定头文件。

#2


4  

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.

doxygen有一个文件依赖关系图作为它的几个输出之一。这可能不是你想要的,但却是个开始。

#3


1  

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

我知道这不是开源(或linux,你别提你的问题,但在你的标签),但我发现这个问题的最佳解决方案是ProFactor IncludeManager——这是最好的回答一个问题几乎完全欺骗的我问你的问题,-开源位(因此为什么我没有你的问题标记为一个欺骗我的)。

#4


0  

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

以前被问过很多次。一直都是同一个答案——多氧基。