g++ 即使指定了标头也找不到标头

g++ can't find headers even when it's specified

本文关键字:找不到 g++      更新时间:2023-10-16

所以基本上我有一些非常简单的代码,其中包括驻留在/Users/wen/Projects/include/bigint中的<BigIntegerLibrary.hh>。我正在编译这个:

g++ main.cpp -o Main -I/Users/wen/Projects/include/bigint

但它报告了一个致命错误,即找不到该文件。我做得对吗?谢谢!

main.cpp:4:10: fatal error: 'BigIntegerLibrary.hh' file not found

尝试

#include "BigIntegerLibrary.hh"

如果使用尖括号 ( #include <includeFile.h>) 指定 #included 文件,编译器将尝试在预定义的位置找到它,而如果您使用#include "includeFile"编译器首先尝试使用 -I 编译器选项指定的路径。

-I编译器选项不能用于指定<...>文件的位置。

如果路径正确g++应该会看到文件。

如果在包含指令中使用绝对路径,则应更改引号:

#include "/Users/wen/Projects/include/bigint/BigIntegerLibrary.hh"