C++ 包含来自#include "DevEngine/Core.h" 的错误

C++ include error from #include "DevEngine/Core.h"

所以有 1 个文件我想 link 在一起,Core.h 和 Events.h。

Core.h 在名为 DevEngine 的文件夹中,Events.h 文件在名为 Events 的文件夹中 在 DevEngine 中。

文件目录如下:

我添加了一个 #include "DevEngine/Core.h":无法打开包含文件:'DevEngine/Core.h':没有这样的文件或目录 DevEngine。不知道哪里出错了

我试过:#include "../DevEngine/Core.h"。那仍然给我一个错误。

你可以#include "../Core.h".

您还可以设置编译器用于搜索头文件的目录(-I option in gcc) and then use paths to those files relative to one of those directories. (See for example gcc documentation on search paths。)

根据您构建项目的方式,这可能会有所不同。

对于 Visual Studio,在 this thread 中查找。

对于 CMake,使用 include_directories