C ++ GLFW GLEW LINK2019未解析的外部符号__imp__glDrawArrays @ 12在函数_main和LINK1120中引用1未解析的外部

时间:2017-08-13 06:30:56

标签: 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 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;
}

并且继承人链接 - &gt;输入 - &gt;我提出的附加依赖

glfw3.lib
glfw3dll.lib
glew32.lib
glew32s.lib

btw我正在使用VS 2017作为ide

0 个答案:

没有答案