OpenGL Pgm 编译期间出现“未定义引用”错误(freeglut3)

OpenGL Pgm 编译期间出现“未定义引用”错误(freeglut3)

我尝试在 Ubuntu 14.04 中运行 openGL pgm,并且安装了 freeglut3 和 dev。但它向我在 pgm 中使用的所有函数返回了一些“未定义的引用”。

rahul@rahul-System-Product-Name:~$ g++ -lGL -lGLU -lglut nrs1.c
/tmp/ccIsCRgh.o: In function `myInit()':
nrs1.c:(.text+0x2a): undefined reference to `glClearColor'
nrs1.c:(.text+0x37): undefined reference to `glPointSize'
nrs1.c:(.text+0x43): undefined reference to `glMatrixMode'
nrs1.c:(.text+0x48): undefined reference to `glLoadIdentity'
nrs1.c:(.text+0x88): undefined reference to `glOrtho'
nrs1.c:(.text+0xca): undefined reference to `gluLookAt'
nrs1.c:(.text+0xd6): undefined reference to `glMatrixMode'
nrs1.c:(.text+0xdb): undefined reference to `glLoadIdentity'
/tmp/ccIsCRgh.o: In function `triangle(float*, float*, float*)':
nrs1.c:(.text+0xee): undefined reference to `glVertex3fv'
nrs1.c:(.text+0xf9): undefined reference to `glVertex3fv'
nrs1.c:(.text+0x104): undefined reference to `glVertex3fv'
/tmp/ccIsCRgh.o: In function `tetra(float*, float*, float*, float*)':
nrs1.c:(.text+0x118): undefined reference to `glColor3fv'
nrs1.c:(.text+0x13d): undefined reference to `glColor3fv'
nrs1.c:(.text+0x162): undefined reference to `glColor3fv'
nrs1.c:(.text+0x187): undefined reference to `glColor3fv'
/tmp/ccIsCRgh.o: In function `display()':
nrs1.c:(.text+0x4cb): undefined reference to `glClear'
nrs1.c:(.text+0x4d7): undefined reference to `glBegin'
nrs1.c:(.text+0x50e): undefined reference to `glEnd'
nrs1.c:(.text+0x513): undefined reference to `glFlush'
/tmp/ccIsCRgh.o: In function `main':
nrs1.c:(.text+0x530): undefined reference to `glutInit'
nrs1.c:(.text+0x53c): undefined reference to `glutInitDisplayMode'
nrs1.c:(.text+0x550): undefined reference to `glutInitWindowSize'
nrs1.c:(.text+0x564): undefined reference to `glutInitWindowPosition'
nrs1.c:(.text+0x570): undefined reference to `glutCreateWindow'
nrs1.c:(.text+0x57c): undefined reference to `glutDisplayFunc'
nrs1.c:(.text+0x588): undefined reference to `glEnable'
nrs1.c:(.text+0x592): undefined reference to `glutMainLoop'

请提出解决方案。谢谢。

相关内容