c - 如何找到源代码的依赖关系?
问题描述
假设我有一个简单的c库项目,布局如下
- src/
- square_root.c
- log.c
- power.c
- newton_method.c
- include/
- square_root.h
- log.h
- power.h
- newton_method.h
现在,我想创建一个简单的程序(main.c)来调用 square_root()
# main.c
# include "square_root.h"
int main()
{
printf("%f\n", square_root(4.0));
return 0;
}
要编译 main.c,必须将 newton_method.c 包含在构建中。
gcc main.c src/square_root.c src/newton_method.c -o main
在这种情况下,newton_method.c 是 square_root.c 的依赖项。如果库很大或编写不佳,则很难找到源代码的依赖项。当然,可以在构建过程中包含所有 *.c,但这会使构建过程变得缓慢和笨拙。
我试过了
gcc -H -MM -M main.c
但它只给了我 *.h 而不是 *.c
是否有任何工具可以查找源代码的依赖项?
解决方案
推荐阅读
- django - 如何重新排序 Django-Graphene 子查询?
- python - 使用 Colab 访问本地文件夹
- jquery - 使用 Select2 禁用自动完成输入
- c# - 如何在 Azure 中的两个公共 Web 应用程序之间共享信息
- tsql - 联合选择过滤
- java - mvn 测试失败,但如果按包运行则测试通过
- php - 使用 docker 在 CentO 上设置 PHP-FPM、Nginx、Mariadb
- android - 如何在 kotlin 正则表达式语句中使用正则表达式开始标记 (^)
- java - 使用 Thymeleaf 和 Spring 动态链接到图像
- java - java为dayOfWeek创建日期和没有特定日期的时间,即对任何星期一都有效