我正在尝试从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
答案 0 :(得分:0)
GLBatch上的快速谷歌给了我一个提示,你可能需要添加链接这个库以及gltools.lib,试试看,让我知道。