OpenGL代码块编译问题win7

时间:2014-10-14 14:18:43

标签: c++ opengl codeblocks glut glu

我正在尝试使用我的代码配置OpenGL :: blocks。

64位Windows 7,Code :: Blocks v.13.12

试图编译简单的代码:

#include <GL/glut.h>

void Draw() {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glBegin(GL_LINES);
        glVertex3f(0.25, 0.25, 0.0);
        glVertex3f(0.75, 0.75, 0.0);
    glEnd();
    glFlush();
}

void Initialize() {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main(int iArgc, char** cppArgv) {
    glutInit(&iArgc, cppArgv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(250, 250);
    glutInitWindowPosition(200, 200);
    glutCreateWindow("XoaX.net");
    Initialize();
    glutDisplayFunc(Draw);
    glutMainLoop();
    return 0;
}

但是有一些错误,我不知道该如何处理。

||=== Build: Debug in test (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `glutInit_ATEXIT_HACK':|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\..\include\GL\glut.h|486|undefined reference to `__glutInitWithExit'|
obj\Debug\main.o||In function `glutCreateWindow_ATEXIT_HACK':|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\..\include\GL\glut.h|503|undefined reference to `__glutCreateWindowWithExit'|
obj\Debug\main.o||In function `glutCreateMenu_ATEXIT_HACK':|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\..\include\GL\glut.h|549|undefined reference to `__glutCreateMenuWithExit'|
obj\Debug\main.o||In function `Z4Drawv':|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|11|undefined reference to `_imp__glClear'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|12|undefined reference to `_imp__glColor3f'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|13|undefined reference to `_imp__glBegin'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|14|undefined reference to `_imp__glVertex3f'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|15|undefined reference to `_imp__glVertex3f'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|16|undefined reference to `_imp__glEnd'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|17|undefined reference to `_imp__glFlush'|
obj\Debug\main.o||In function `Z10Initializev':|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|21|undefined reference to `_imp__glClearColor'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|22|undefined reference to `_imp__glMatrixMode'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|23|undefined reference to `_imp__glLoadIdentity'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|24|undefined reference to `_imp__glOrtho'|
obj\Debug\main.o||In function `main':|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|29|undefined reference to `glutInitDisplayMode'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|30|undefined reference to `glutInitWindowSize'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|31|undefined reference to `glutInitWindowPosition'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|34|undefined reference to `glutDisplayFunc'|
C:\Users\Admin\Desktop\OpenGL\test\main.cpp|35|undefined reference to `glutMainLoop'|
||=== Build failed: 19 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

我该怎么做才能解决它?

0 个答案:

没有答案