在 c++ 中找不到头文件,可能的路径问题
Header files not found in c++, possible path issue
我有一个这样的文件结构:
main.cpp --> #include <headers/f1/v.h>
headers/f1/v.h --> #include <headers/f1/i.h>
headers/f1/i.h
headers
是外部库的目录。使用"g++ main.cpp"编译并得到文件未找到错误:
In file included from main.cpp:11:
./headers/f1/v.h:32:10: fatal error: 'headers/f1/i.h' file not found
#include <headers/f1/i.h>
对 c++ 非常陌生。真的想不通。这里出了什么问题?谢谢!
在同一构建树中包含自己的标头时,应使用引号而不是尖括号:
#include "headers/f1/v.h"
如果您确实遇到需要<>
本地文件的情况,无论出于何种原因,都可以将目录添加到编译器的包含路径中:
g++ main.cpp -I .
其中.
是"此目录"的 POSIX 约定。
延伸阅读:
- #include <文件名>和 #include"文件名"有什么区别?文件名>
相关文章:
- CMake 错误"源似乎不包含 CMakeLists.txt",路径/库连接问题
- 有效地将大数存储为 2 的幂用于路径问题
- 使用 Libssh 将文件从服务器复制到客户端:分配文件复制目标路径时出现问题
- 我最近更改了编译器路径以运行 c++ 代码,但现在我无法运行任何 python 代码。我该如何解决这个问题?
- 按名称问题获取卸载应用程序路径
- 从另一个应用启动我的应用时出现相对路径更改问题
- 问题在具有依赖性时从其他路径上加载DLL的DLL
- 程序文件中的安装路径:一些问题
- 在 c++ 中找不到头文件,可能的路径问题
- Visual Studio:C++\CLI 包装程序集路径依赖性问题
- 班级路径问题 - getJnienv失败了
- 最短路径问题与一个变化
- 我的递归算法中的问题,用于查找所有最短、唯一的路径
- 编译C++中动态链接库,存在运行路径问题
- IOS上的OpenCV haar级联了C++中的xml文件路径问题
- 问题包括来自不同目录的头文件[不是路径问题]
- Boost::iostreams::mapped_file文件路径问题
- c++文件路径问题
- 弗洛伊德算法(最短路径)问题 - C++
- 为c++在Eclipse中添加Boost - include路径问题