Eclipse 没有从单独的文件夹中看到我的 c++ 包含
Eclipse does not see my c++ includes from separate folders
我有以下文件夹文件层次结构:
src/
Fuelable.h
Fuelables/
PetrolCar.h
PetrolCar.cpp
汽油车:
#include "Fuelable.h"
汽油车.cpp:
#include "PetrolCar.h"
为了进行此编译,我添加了src文件夹以包含本手册中的路径:http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_proj_paths.htm
包含代码不会突出显示为错误。但是当我尝试构建它失败并显示有关 makefile 的错误时:
Building file: ../src/Fuelables/PetrolCar.cpp
In file included from ../src/Fuelables/PetrolCar.cpp:8:0:
Invoking: GCC C++ Compiler
../src/Fuelables/PetrolCar.h:12:22: fatal error: Fuelable.h: No such file or directory
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Fuelables/PetrolCar.d" -MT"src/Fuelables/PetrolCar.d" -o "src/Fuelables/PetrolCar.o" "../src/Fuelables/PetrolCar.cpp"
compilation terminated.
make: *** [src/Fuelables/PetrolCar.o]
有趣的是,智能可以看到所有文件。
如果我从命令行编译:
sashko@sashko-1225C:~/workspaceEclipse/FuelingSystem/src/Fuelables$ g++ PetrolCar.cpp -I
/home/sashko/workspaceEclipse/FuelingSystem/src/Fuelable.h
cc1plus: warning: /home/sashko/workspaceEclipse/FuelingSystem/src/Fuelable.h: not a directory [enabled by default]
In file included from PetrolCar.cpp:8:0:
PetrolCar.h:12:22: fatal error: Fuelable.h: No such file or directory
compilation terminated.
假设您将分发一个库机器。包含层次结构可以是:
some_local_or_general_or_system_include_directory
- Machines
- Fuelables
然后,您可以#include <Machines/Fuelable.h>
或#include <Machines/Fuelables/PetrolCar.h>
具有单个包含目录。否则,您必须将每个目录添加到包含路径。
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 我的字符计数代码计算错误.为什么
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- cmake在我的项目中所需的所有静态库都不成功
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 为什么我的for循环不能正确获取argv
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 0-1背包代码中的错误.我的代码中有什么错误
- 当我的阵列太大时出现分段错误
- 如何确认我的constexpr表达式实际上已经在编译时执行
- 为什么二进制搜索在我的测试中不起作用
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 当我在main中声明了我的2d数组时,为什么我的程序会退出
- OpenGL在启用深度测试时不会丢弃我的碎片
- 为什么我的 std::ref 无法按预期工作?
- clang整洁10忽略了我的NOLINT命令
- 为什么我的删除节点函数实际上没有删除节点?