0

我正在尝试从 opengl 教程编译以下程序,但遇到了这些奇怪的错误。我不知道如何解决这些问题,求助。IDE 代码块 12.11、Windows 7 32 位、gcc 4.7.1

这是代码

#include <GLTools.h>
#include <GL/glut.h>
#include <GLShaderManager.h>
GLBatch triangleBatch;
GLShaderManager shaderManager;
void ChangeSize(int w, int h)
{
    glViewport(0, 0, w, h);
}

void SetupRC()
{
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f );
    shaderManager.InitializeStockShaders();
    GLfloat vVerts[] = { -0.5f, 0.0f, 0.0f,
                          0.5f, 0.0f, 0.0f,
                          0.0f, 0.5f, 0.0f };
    triangleBatch.Begin(GL_TRIANGLES, 3);
    triangleBatch.CopyVertexData3f(vVerts);
    triangleBatch.End();
}
void RenderScene(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f };
    shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
    triangleBatch.Draw();
    glutSwapBuffers();
}
int main(int argc, char* argv[])
{
    gltSetWorkingDirectory(argv[0]);
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
    glutInitWindowSize(800, 600);
    glutCreateWindow("Triangle");
    glutReshapeFunc(ChangeSize);
    glutDisplayFunc(RenderScene);
    GLenum err = glewInit();
    if (GLEW_OK != err) {
        fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
        return 1;
    }
SetupRC();
glutMainLoop();
return 0;
}

错误-

undefined reference to    GLShaderManager::InitializeStockShaders()
undefined reference to GLBatch::Begin(unsigned int, unsigned int, unsigned int)
undefined reference to GLBatch::End()
undefined reference to GLShaderManager::UseStockShader(GLT_STOCK_SHADER, ...)
undefined reference to GLBatch::Draw()
undefined reference to gltSetWorkingDirectory(char const*)
undefined reference to GLBatch::~GLBatch()
undefined reference to GLShaderManager::~GLShaderManager()
undefined reference to GLBatch::GLBatch()
undefined reference to GLShaderManager::GLShaderManager()
undefined reference to GLBatch::CopyVertexData3f(float (*) [3])
||=== Build finished: 11 errors, 0 warnings (0 minutes, 2 seconds) ===||

链接的库 -lmingw32 -lglut32 -lglew32 -lglu32 -lgltools -lopengl32

4

1 回答 1

0

GLBatch 上的快速谷歌给了我一个提示,ypou 可能必须添加链接这个库以及 gltools.lib,试试这个并告诉我。

于 2013-06-19T12:56:11.803 回答