我正在尝试在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
任何人都可以为此提供解决方案吗?我会很感激的!