【发布时间】:2021-11-07 22:05:27
【问题描述】:
背景故事
-
我正在制作一个用于自学的小型游戏引擎项目/我正在使用 Vulkan 图形 API 和 GLFW,我使用 CMake 编译它。在编译时一切正常,但是在 VSCode 中编写代码时,它会给我错误的错误提示
cannot open source file "GLFW/glfw3.h"C/C++(1696)。即使我继续编译并将其包含到主文件中,它也可以按预期工作。 -
我已尝试重新启动 VSCode、重新启动计算机、重建 CMake 和删除缓存,尝试使用
<>和""进行包含,并使用 VSCode 建议将其再次包含在 CPP 属性文件中。 -
重要的一点是,如果我将相同的代码包含到我的
main.cpp文件中,一切正常,但是在我将代码分成单独的文件并尝试包含 GLFW 后,问题就开始出现了。
文件结构:
+-> .vscode
| |
| +-> c_cpp_properties.json
| +-> settings.json
|
+-> bin
| |
| +-> Abyssal.exe
|
+-> build (CMake build files)
|
+-> src
| |
| +-> AbyssalWindow.h
| +-> main.cpp
|
+-> vendor (nothing inside this folder)
+-> CMakeLists.txt
{
"env": {
"myDefaultIncludePath": [
"${workspaceFolder}",
"${workspaceFolder}/src"
]
},
"configurations": [
{
"name": "Windows",
"intelliSenseMode": "${default}",
"includePath": [
"${myDefaultIncludePath}",
"C:/VulkanSDK/1.2.189.0/Include",
"C:/glfw-3.3.4/include"
],
"cStandard": "c17",
"cppStandard": "c++17",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
【问题讨论】:
标签: c++ visual-studio-code cmake include