gcc在c中相对于彼此包含子目录中的源文件

问题描述

我在编译某些C代码时遇到问题。

我的代码结构如下

  • main.c
  • src
      • line.h
      • line.c

在此处可用:https://github.com/Vafilor/c_includes

main.c包括#include "src/line/line.h"

src/line/line.c包括#include "src/line/line.h"

当我尝试在ubuntu 20.4上使用gcc main.c src/line/line.c进行编译时

我收到此错误

src/line/line.c:1:10: Fatal error: src/line/line.h: No such file or directory
    1 | #include "src/line/line.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.

如何获取文件

其他信息:

我一直在查看https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/上的bluez代码 他们有类似的东西

  • client/main.c-包括shell.h
  • src/shared/shell.c-包括shell.h
  • src/shared/shell.h

所以我想弄清楚它在他们的代码库中是如何工作的。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)