错误消息:无法打开"KHR/khrplatform.h",但程序中不存在"khrplatform"
Error message: "KHR/khrplatform.h" cannot be opened, but "khrplatform" does not exist anywhere within the program
我正试图在OpenGL中打开一个窗口。在VisualStudio中,我用我的所有头文件(如glfw3.h和greed.h)设置了一个include目录。我的include语句格式正确:
#include <glad/glad/glad.h>
#include <GLFW/glfw3.h>
有一个额外的"高兴/",因为在文件资源管理器中有一个多余的高兴文件夹。include文件夹中包含的另一个头文件是"khrplatform.h"。这是目录序列:
include/gree/KHR/khrplatform.h
这是我为打开窗口而写的代码:
#include <glad/glad/glad.h>
#include <GLFW/glfw3.h>
int main() {
glfwInit(); //initializes the openGL window
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //This line and the next set the desired version of glfw (major.minor)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //sets openGL to the core profile (fewer functions)
return 0;
}
在我的visualstudio项目中还有一个gread.c文件,它对于窗口打开编程是必要的。我得到的错误消息将错误指定为greed.c文件中的错误。错误如下:
1>------ Build started: Project: OpenGL_SampleProject, Configuration: Debug Win32 ------
1>glad.c
1>c:usersdaviddocumentsopengllibs_includeincludegladgladglad.h(95): fatal error C1083: Cannot open include file: 'KHR/khrplatform.h': No such file or directory
1>Done building project "OpenGL_SampleProject.vcxproj" -- FAILED.
问题是文本"khrplatform.h"根本没有出现在greed.c中。所以我不知道这个bug是从哪里来的。有设置和使用OpenGL经验的人能为我回答这个问题吗?
在greed.h中,包含了khrplatform.h。使用的确切语法是:
#include <KHR/khrplatform.h>
因为您添加了另一个高兴的文件夹,所以您将包含目录设置得太高了一级。这意味着高兴.h实际上应该引用:
#include <glad/KHR/khrplatform.h>
如果你的文件夹结构是这样的:
-依赖项(在Visual Studio中设置为包含目录)
----高兴
-------高兴
----------高兴.h
-------KHR
----------khr平台.h
您必须将包含目录更改为:
-依赖
----greed(在Visual Studio中设置为include目录)
-------高兴
----------高兴.h
-------KHR
----------khr平台.h
因为这将使greed.h中的<KHR/khrplatform.h>
正确。
你也可以去掉那个额外的文件夹,但如果你真的想保留它,你必须在visualstudio中更改包含目录。
您要更改的具体设置如下所示:
右键单击解决方案资源管理器中的项目名称->属性->C/C++->常规
在"附加包含目录"设置下,您必须将路径更改为上述路径。
或者,你可以更改greed.h文件,但我不建议这样做。因为你可能会在未来的某个时候更新greed,这意味着你将不得不再次手动更改那行代码。
- 我们可以访问一个不存在的联盟的成员吗
- C++:对不存在的命名空间使用命名空间指令
- g++ 说函数不存在,即使包含正确的标头
- 显式 std::exception_ptr 转换为 bool 不存在.VS2010 错误?
- C++ 尝试在不存在的构造函数中引用已删除的函数(使用 rapidJson)
- 查找第一个数组中不存在的元素
- 查找不存在的键时,unordered_map返回什么
- 如何优化代码以返回最接近给定整数的数字,但给定列表中不存在?
- set::find 查找不存在的元素
- 有没有办法将字符串添加到 Vector 中,但前提是它尚不存在?->C++
- inet_ntop返回不存在的地址
- CPP 使用不存在的键访问映射
- 为什么QMediaGaplessPlaybackControl不存在?
- 如果键不存在,使用 [] 运算符访问 STL Map 元素会添加新元素
- 标记未定义的颜色,并且颜色匹配系统中不存在样品
- 为什么minhook库目录不存在
- 为什么 std::vector::p ush_front() 不存在?
- 不存在从"Magick::Color"到"MagickCore::Quantum"的合适转换功能
- 为什么 MDI 子窗口在WM_NCCREATE后不存在?
- 错误消息:无法打开"KHR/khrplatform.h",但程序中不存在"khrplatform"