error LNK2001: 无法解析的外部符号 _glad_glViewport
学习OpenGL时compile遇到这个问题,头疼了半天时间,谁帮我解答一下
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
// settings
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
while (!glfwWindowShouldClose(window))
{
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
1>------ 已启动生成: 项目: ConsoleApplication3, 配置: Debug Win32 ------
1>First.cpp
1>First.obj : error LNK2019: 无法解析的外部符号 _gladLoadGLLoader,该符号在函数 _main 中被引用
1>First.obj : error LNK2001: 无法解析的外部符号 _glad_glViewport
1>E:\OpenGL\OpenGL_Study\First\Debug\ConsoleApplication3.exe : fatal error LNK1120: 2 个无法解析的外部命令
1>已完成生成项目“ConsoleApplication3.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========