C++ C++;GLFW GLEW LINK2019和x9;未解析的外部符号\uuu imp__glDrawArrays@12函数_main和LINK1120 1中引用的未解析外部
我使用glfw和glew只是为了测试在屏幕上绘制三角形,但是当我添加代码来绘制三角形时,它会给我一个LINK2019未解析的外部符号和LINK1120 1未解析的外部错误C++ C++;GLFW GLEW LINK2019和x9;未解析的外部符号\uuu imp__glDrawArrays@12函数_main和LINK1120 1中引用的未解析外部,c++,visual-studio-2017,C++,Visual Studio 2017,我使用glfw和glew只是为了测试在屏幕上绘制三角形,但是当我添加代码来绘制三角形时,它会给我一个LINK2019未解析的外部符号和LINK1120 1未解析的外部错误 #include <stdlib.h> #include <stdio.h> #include <iostream> #include <GL\glew.h> #include <GLFW\glfw3.h> using namespace std; int ma
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <GL\glew.h>
#include <GLFW\glfw3.h>
using namespace std;
int main() {
if (!glfwInit()) {
fprintf(stderr, "GLFW has failed to initialize");
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(640, 480, "My OpenGL", NULL, NULL);
if (!window) {
fprintf(stderr, "Window has failed to initialize");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental = true;
if (glewInit() != GLEW_OK) {
fprintf(stderr, "GLEW failed to initialize");
glfwTerminate();
return -1;
}
GLuint vaoID;
glGenVertexArrays(1, &vaoID);
glBindVertexArray(vaoID);
static const GLfloat verts[] = {
// x, y, z
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f
};
GLuint vboID;
glGenBuffers(1, &vboID);
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
while (!glfwWindowShouldClose(window)) {
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(vboID, sizeof(verts), verts, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
顺便说一句,我使用VS 2017作为ide您还需要链接opengl32.libty它现在可以工作,但是没有三角形,但是我知道为什么我没有添加着色器您还需要链接opengl32.libty它现在可以工作,但是没有三角形,但是我知道为什么我没有添加着色器
glfw3.lib
glfw3dll.lib
glew32.lib
glew32s.lib