I'm trying to write a plotting program with c++ under ubuntu12.04. OpenGL is applicated in my code. I have included the necessary header files, but the openGL function still cannot be used.
/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
Can anyone have a solution for this? I will appreciate that!