【问题标题】:Why can't gcc find the include path using -I option?为什么 gcc 使用 -I 选项找不到包含路径?
【发布时间】:2023-03-20 19:15:01
【问题描述】:

这是我的项目树

project  
--bin  
--source  
----include  
------foo.h  
----main.c  
----foo.c

但是当我运行 gcc -I./source/include ./bin/main.exe ./source/*.c 时,它给了我 No such file or directory 错误。
如何让 gcc 知道包含目录在哪里?

【问题讨论】:

  • 因为你传递的是相对路径,所以在调用gcc之前确保你cdproject

标签: c gcc include


【解决方案1】:

您需要使用 -o 选项运行 gcc 来设置输出位置。

gcc -I./source/include -o ./bin/main.exe ./source/*.c

【讨论】:

    猜你喜欢
    • 2013-07-30
    • 1970-01-01
    • 2012-09-03
    • 2018-05-07
    • 1970-01-01
    • 2011-04-03
    • 1970-01-01
    • 2012-02-29
    相关资源
    最近更新 更多