(编译器错误)为什么C++找不到.h文件,即使它在那里?

Cur*_*ous 2 c++ compiler-errors

我正在尝试运行一个C++文件,即experiment.cpp.在编译.cpp文件时,我收到RL_glue.h不存在的错误,即使RL_glue.h与C++文件位于同一目录中.我很乐意就此问题征求您的意见.谢谢!

包括如下:

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <RL_glue.h>
#include <RL_common.h>
Run Code Online (Sandbox Code Playgroud)

虽然我按照评论的建议改变了它:

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include "RL_glue.h"
#include "RL_common.h"
Run Code Online (Sandbox Code Playgroud)

我使用的编译器是gcc 4.6.3,编译命令是g ++ -Wall -c"%f"

更正:通过"...."更改,编译器找到RL_glue.h,但是,它在查找RL_common.h时特别失败.

确切的编译器错误:

g++ -Wall -c "experiment.cpp" (in directory: /home/issam/Helicopter_Control/Code/Release)
In file included from experiment.cpp:9:0:
./RL_glue.h:4:23: fatal error: RL_common.h: No such file or directory
compilation terminated.
Compilation failed.
Run Code Online (Sandbox Code Playgroud)

rod*_*igo 5

请注意编译器错误位置:

./RL_glue.h:4:23
Run Code Online (Sandbox Code Playgroud)

错误在于RL_glue.h包含RL_common.h,而不是包含在该文件中.那是因为在RL_glue.h文件的第4行中有类似的东西:

#include <RL_common.h>
Run Code Online (Sandbox Code Playgroud)

代替:

#include "RL_common.h"
Run Code Online (Sandbox Code Playgroud)

您可以替换该行,甚至更容易添加-I.到编译器选项,以便.搜索当前目录,无论包含样式.