【发布时间】:2018-08-05 16:24:05
【问题描述】:
我正在尝试将 Visual Studio 中的 GLFW 用于 Vulkan 项目。
在所有包含语句之后,代码仍然显示一些错误,所有这些都与 GLFW 库包含有关。
一个错误(下面的最后一个)有“stdafx.h”错误。
我不知道stdafx.h 是什么。
我正在发布代码和错误。
有人可以帮我解决这个问题吗?
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include <iostream>
int main() {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow* window = glfwCreateWindow(800, 600, "Vulkan window", nullptr, nullptr);
uint32_t extensionCount = 0;
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
std::cout << extensionCount << " extensions supported" << std::endl;
glm::mat4 matrix;
glm::vec4 vec;
auto test = matrix * vec;
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
严重性代码描述项目文件行抑制状态错误 (active) E1696 无法打开源文件 "GLFW/glfw3.h" VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 2
错误(活动)E0020 标识符“glfwInit”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 9
错误(活动)E0020 标识符“glfwWindowHint”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 10
错误(活动)E0020 标识符“GLFW_CLIENT_API”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 10
错误(激活)E0020 标识符“GLFW_NO_API”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 10
错误(激活)E0020 标识符“GLFWwindow”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 11
错误(活动) E0020 标识符“窗口”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 11
错误(活动)E0020 标识符“glfwCreateWindow”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 11
错误(激活)E0020 标识符 “vkEnumerateInstanceExtensionProperties”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 13
错误(活动)E0020 标识符“glfwWindowShouldClose”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 18
错误(活动)E0020 标识符“glfwPollEvents”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 19
错误(活动)E0020 标识符“glfwDestroyWindow”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 21
错误(活动)E0020 标识符“glfwTerminate”是 未定义 VulkanTest c:\Users\H281525\source\repos\VulkanTest\VulkanTest\main.cpp 22
查找预编译时出现错误 C1010 文件意外结束 标题。您是否忘记将 '#include "stdafx.h"' 添加到您的 资源? VulkanTest c:\users\h281525\source\repos\vulkantest\vulkantest\main.cpp 25
【问题讨论】:
-
欢迎来到 Stack Overflow!为了给您一个很好的答案,如果您还没有看过How to Ask,它可能会对我们有所帮助。如果您可以提供minimal reproducible example,它可能也很有用。