开源工具可视化C / C ++头文件依赖关系? [英] Open-source tool to visualize C/C++ header file dependencies?

查看:2183
本文介绍了开源工具可视化C / C ++头文件依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要找的是一个工具,给定一个根源文件,输出一个文件依赖关系的图形(带一些自定义,当然,像--maxdepth等)

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

推荐答案

对于不耐烦,谁,像我一样,只是想要一个命令列表,而不是RTFM :)所以不用进一步(假设你有Debian,它的ilk)...

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

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

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

apt-get install doxygen graphviz

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

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

doxygen -g

这将导致在当前目录中生成一个新的配置文件,称为Doxyfile。然后,您可以使用自己喜欢的文本编辑器修改它。请务必将以下标记设置为指定的值:

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

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

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

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

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

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

现在,如果你很幸运,可以将浏览器指向文件/ tmp / foobar / doc /html/index.html,选择文件选项卡,然后单击头文件以查看两个不错的图:一个显示哪些头文件包括在头文件(直接或间接),而另一个显示什么其他文件直接或间接包含给定的头文件。

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.

这篇关于开源工具可视化C / C ++头文件依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆