c - 如何让 makefile 正确识别多个目录中的包含
问题描述
由于编译时出现包含错误,我一直在努力让我的 make 文件正确编译我的所有源文件。我在网上查看了一些问题,但解决方案似乎无法解决我的问题。
如果我将所有源文件都放在同一个目录中,我可以编译这个程序,但是一旦我尝试将文件拆分到单独的目录中,它就不再起作用了。
这是错误:
~/Documents/GitHub/testing$ make build
gcc -I/. -Wall main.c inplementation/inplementation.c -o program.exe
In file included from main.c:3:
./inplementation/inplementation.h:4:10: fatal error: 'module/module.h' file not found
\#include "module/module.h"
1 error generated.
In file included from inplementation/inplementation.c:1:
inplementation/inplementation.h:4:10: fatal error: 'module/module.h' file not found
\#include "module/module.h"
1 error generated.
make: *** [build] Error 1
这是我的文件目录的屏幕截图:
解决方案
您使用#include "module/module.h"
while 包含标志是-I/$(TESTING_DIR)/module
.
首先,我认为您可能的意思是-I$(TESTING_DIR)/module
,否则您将在存储的路径之前添加一个额外的斜杠TESTING_DIR
。
但主要问题是该文件夹module/module.h
下不存在。module
因此,您需要执行以下组合之一:
-I$(TESTING_DIR)/module
和#include "module.h"
-I$(TESTING_DIR)
和#include "module/module.h"
推荐阅读
- git - git cherry-pick 以编程方式从合并中挑选
- angular - 我从 GET 方法收到的数据没有在 html 页面上更新
- bluetooth - Raspberry Pi 的蓝牙网状网络
- math - 来自 OpenGL 的标准化设备坐标金属
- c# - 即使 XML 有数据,C# 中的 XML 反序列化也会返回空数组
- android - 如何在连接/断开 ADB 时自动启用/禁用开发人员选项保持清醒设置?
- asp.net - 在 docker 容器内运行 ASP.NET 4.6 应用程序 - 站点总是 404s
- python - U-Net(Keras)中的加权二元交叉熵
- javascript - JavaScript 获取时间函数
- vhdl - 如何检查支持哪些 VHDL2008 功能?