2019 年 Visual Studio 无法包含 GLFW/glfw.h
Unable to include GLFW/glfw.h on Visual Studio 2019
我正在为 C++ OpenGL 设置 Visual Studio。我尝试按照 youtube (https://www.youtube.com/watch?v=OR4fNpBjmq8) 上的教程进行操作,但它仍然不断出现此错误:"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;
}
和GLFW官网的demo一模一样,但是不能用。有什么办法可以解决这个问题?
It is exact same as the demo on the official GLFW website but it does
not work. Any way to fix this?
感谢您与我分享教程,我已遵循此指南,这在我这边有效并且构建没有任何错误。因此,请按照我的步骤来解决您的问题:
1) 将 glfw3.h
的路径添加到 Additional Include Directories(右键单击您的项目--> Configuration Properties
-->C/C++
-->General
-->Additional Include Directories
).
2) add glfw3.lib
into Additional Dependencies(右击项目-->Configuration Properties
-->Linker
-->Input
-->Additional Dependencies
) 不要忘记在其中添加 opengl32.lib
3) 关闭,重新打开 VS 然后你将重建你的项目没有任何错误。
另外,调试时如果想进入glfw3.h
文件查看其功能,需要将路径添加到库目录(右击项目-->Configuration Properties
-->VC++ Directories
-->Library Directories
).
希望对您有所帮助。
我正在为 C++ OpenGL 设置 Visual Studio。我尝试按照 youtube (https://www.youtube.com/watch?v=OR4fNpBjmq8) 上的教程进行操作,但它仍然不断出现此错误:"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;
}
和GLFW官网的demo一模一样,但是不能用。有什么办法可以解决这个问题?
It is exact same as the demo on the official GLFW website but it does not work. Any way to fix this?
感谢您与我分享教程,我已遵循此指南,这在我这边有效并且构建没有任何错误。因此,请按照我的步骤来解决您的问题:
1) 将 glfw3.h
的路径添加到 Additional Include Directories(右键单击您的项目--> Configuration Properties
-->C/C++
-->General
-->Additional Include Directories
).
2) add glfw3.lib
into Additional Dependencies(右击项目-->Configuration Properties
-->Linker
-->Input
-->Additional Dependencies
) 不要忘记在其中添加 opengl32.lib
3) 关闭,重新打开 VS 然后你将重建你的项目没有任何错误。
另外,调试时如果想进入glfw3.h
文件查看其功能,需要将路径添加到库目录(右击项目-->Configuration Properties
-->VC++ Directories
-->Library Directories
).
希望对您有所帮助。