问题遇到的现象和发生背景
学习opengl运行glfw官网文档中生成窗口的代码时出现报错:
error LNK2019: 无法解析的外部符号 vkGetInstanceProcAddr,函数 glfwGetInstanceProcAddress 中引用了该符号
vs是2022版本,cmake是3.22.3版本,glfw是3.3.6版本
问题相关代码,请勿粘贴截图
#include <GLFW/glfw3.h>
int main(void)
{
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;
}
运行结果及报错内容
我的解答思路和尝试过的方法
我认为应该是缺少相关库,但没找到应该在input那里链接什么库,考虑是cmake编译glfw出现问题,生成glfw的解决方案时也有一样的报错,但也不知道怎么解决。
我想要达到的结果
想要解决这个错误,并可以正常运行这段代码。