我正在尝试用ubuntu12.04下的c ++编写一个绘图程序。 OpenGL应用于我的代码(cc.cpp)。我已经包含了必要的头文件,但仍然无法使用openGL函数。
这是包含代码。
#include <GL/freeglut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
当我在终端中运行g++ cc.cpp
时,终端显示:
/tmp/ccsiISvK.o: In function `initGL()':
cc.cpp:(.text+0xe): undefined reference to `glMatrixMode'
cc.cpp:(.text+0x13): undefined reference to `glLoadIdentity'
cc.cpp:(.text+0x49): undefined reference to `glOrtho'
cc.cpp:(.text+0x55): undefined reference to `glMatrixMode'
cc.cpp:(.text+0x5a): undefined reference to `glLoadIdentity'
cc.cpp:(.text+0x82): undefined reference to `glClearColor'
cc.cpp:(.text+0x87): undefined reference to `glGetError'
cc.cpp:(.text+0x9b): undefined reference to `gluErrorString'
/tmp/ccsiISvK.o: In function `render()':
cc.cpp:(.text+0x124): undefined reference to `glClear'
cc.cpp:(.text+0x130): undefined reference to `glBegin'
cc.cpp:(.text+0x14f): undefined reference to `glColor3f'
cc.cpp:(.text+0x18b): undefined reference to `glVertex2f'
cc.cpp:(.text+0x1b0): undefined reference to `glEnd'
cc.cpp:(.text+0x1b5): undefined reference to `glutSwapBuffers'
/tmp/ccsiISvK.o: In function `runMainLoop(int)':
cc.cpp:(.text+0x1f7): undefined reference to `glutTimerFunc'
/tmp/ccsiISvK.o: In function `main':
cc.cpp:(.text+0x214): undefined reference to `glutInit'
cc.cpp:(.text+0x228): undefined reference to `glutInitContextVersion'
cc.cpp:(.text+0x234): undefined reference to `glutInitDisplayMode'
cc.cpp:(.text+0x248): undefined reference to `glutInitWindowSize'
cc.cpp:(.text+0x254): undefined reference to `glutCreateWindow'
cc.cpp:(.text+0x27f): undefined reference to `glutDisplayFunc'
cc.cpp:(.text+0x29b): undefined reference to `glutTimerFunc'
cc.cpp:(.text+0x2a0): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
任何人都可以为此解决问题吗?我会很感激的!