无法在 Visual Studio 2019 中包含 GLFW/glfw.h [英] Unable to include GLFW/glfw.h on Visual Studio 2019

查看:244
本文介绍了无法在 Visual Studio 2019 中包含 GLFW/glfw.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 C++ OpenGL 设置 Visual Studio.我尝试按照 youtube 上的教程(

2)glfw3.lib 添加到 Additional Dependencies(右键单击项目-->Configuration Propertiescode>-->Linker-->Input-->Additional Dependencies) 并且不要忘记添加 opengl32.lib 进去

3) 关闭,重新打开 VS,然后您将重建您的项目而不会出现任何错误.

另外,如果你想在调试时进入glfw3.h文件查看它的功能,你应该将路径添加到Library Directorys(右键单击项目-->Configuration Properties-->VC++ Directories-->Library Directories).

希望能帮到你.

I am setting up Visual Studio for C++ OpenGL. I tried following a tutorial on youtube (https://www.youtube.com/watch?v=OR4fNpBjmq8) but it still keep on getting this error: "cannot open source file "GLFW/glfw3.h"

#include <GLFW/glfw3.h>

int main()
{
GLFWwindow* window;

/* Initialize the library */
if (!glfwInit())
    return -1;

/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
    glfwTerminate();
        return -1;
}

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

It is exact same as the demo on the official GLFW website but it does not work. Any way to fix this?

解决方案

It is exact same as the demo on the official GLFW website but it does not work. Any way to fix this?

Thanks for your sharing the tutorial with me and l have followed this guidance and this works in my side and builds without any errors. So please follow my steps to troubleshoot your issue:

1) add the path of glfw3.h into Additional Include Directories(Right-click on your project-->Configuration Properties-->C/C++-->General-->Additional Include Directories).

2) add glfw3.lib into Additional Dependencies(Right-click on the project-->Configuration Properties-->Linker-->Input-->Additional Dependencies) and do not forget to add opengl32.lib into it

3) close,reopen VS and then you will rebuild your project without any errors.

In addition, if you want to enter into glfw3.h file to see its function when you debug it, you should add the path into Library Directories(Right-click on the project-->Configuration Properties-->VC++ Directories-->Library Directories).

Hope it could help you.

这篇关于无法在 Visual Studio 2019 中包含 GLFW/glfw.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆