【问题标题】:Vulkan GLFW include errors in Visual Studio 2017Vulkan GLFW 在 Visual Studio 2017 中包含错误
【发布时间】: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,它可能也很有用。

标签: c++ glfw


【解决方案1】:

E1696 无法打开源文件“GLFW/glfw3.h”

非常不言自明。编译器找不到GLFW/glfw3.h。只需将包含GLFW 文件夹的目录添加到您的Additional Include Directories

E0020 标识符“glfwWhatever”未定义

上面的直接结果,因为#include失败了。

查找预编译头时出现错误 C1010 文件意外结束。

如果您不想使用 Precompiled Header,则只需在项目属性中禁用它即可。否则必须提供(默认stdafx.h

【讨论】:

  • 感谢您的回答。我想通了,代码现在正在运行:D
猜你喜欢
  • 2020-02-12
  • 1970-01-01
  • 2018-10-01
  • 2018-02-13
  • 2017-10-28
  • 2018-08-15
  • 2017-11-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多