我知道存在类似的问题,但我几乎查看了所有问题,却找不到有效的答案。以下是我迄今为止尝试过的命令。
sudo apt-get install freeglut3
sudo apt-get install freeglut3-dev
sudo apt-get install libxmu-dev
sudo apt-get install libxi-dev
dpkg -L freeglut3-dev
我也尝试在 Windows 上执行此操作(我是 Linux 新手),但我也无法在 Windows 上执行此操作。以下是我运行的错误和 gcc 命令
编译:
gcc -lglut bitfont.c
错误:
/usr/bin/ld: /tmp/cc7l7v1G.o: in function `selectFont':
bitfont.c:(.text+0x2f): undefined reference to `glutPostRedisplay'
/usr/bin/ld: /tmp/cc7l7v1G.o: in function `selectColor':
bitfont.c:(.text+0xab): undefined reference to `glColor3f'
/usr/bin/ld: bitfont.c:(.text+0xc2): undefined reference to `glColor3f'
/usr/bin/ld: bitfont.c:(.text+0xe1): undefined reference to `glColor3f'
/usr/bin/ld: bitfont.c:(.text+0xe7): undefined reference to `glutPostRedisplay'
/usr/bin/ld: /tmp/cc7l7v1G.o: in function `tick':
bitfont.c:(.text+0xf7): undefined reference to `glutPostRedisplay'
/usr/bin/ld: /tmp/cc7l7v1G.o: in function `output':
bitfont.c:(.text+0x11f): undefined reference to `glRasterPos2f'
/usr/bin/ld: bitfont.c:(.text+0x15b): undefined reference to `glutBitmapCharacter'
/usr/bin/ld: /tmp/cc7l7v1G.o: in function `display':
bitfont.c:(.text+0x17d): undefined reference to `glClear'
/usr/bin/ld: bitfont.c:(.text+0x1c7): undefined reference to `glutSwapBuffers'
/usr/bin/ld: /tmp/cc7l7v1G.o: in function `reshape':
bitfont.c:(.text+0x1f5): undefined reference to `glViewport'
/usr/bin/ld: bitfont.c:(.text+0x1ff): undefined reference to `glMatrixMode'
/usr/bin/ld: bitfont.c:(.text+0x204): undefined reference to `glLoadIdentity'
/usr/bin/ld: bitfont.c:(.text+0x223): undefined reference to `gluOrtho2D'
/usr/bin/ld: bitfont.c:(.text+0x22d): undefined reference to `glMatrixMode'
/usr/bin/ld: /tmp/cc7l7v1G.o: in function `main':
bitfont.c:(.text+0x256): undefined reference to `glutInit'
/usr/bin/ld: bitfont.c:(.text+0x290): undefined reference to `glutBitmap9By15'
/usr/bin/ld: bitfont.c:(.text+0x2ad): undefined reference to `glutInitDisplayMode'
/usr/bin/ld: bitfont.c:(.text+0x2bc): undefined reference to `glutInitWindowSize'
/usr/bin/ld: bitfont.c:(.text+0x2c8): undefined reference to `glutCreateWindow'
/usr/bin/ld: bitfont.c:(.text+0x2e1): undefined reference to `glClearColor'
/usr/bin/ld: bitfont.c:(.text+0x2ed): undefined reference to `glutDisplayFunc'
/usr/bin/ld: bitfont.c:(.text+0x2f9): undefined reference to `glutReshapeFunc'
/usr/bin/ld: bitfont.c:(.text+0x305): undefined reference to `glutIdleFunc'
/usr/bin/ld: bitfont.c:(.text+0x311): undefined reference to `glutCreateMenu'
/usr/bin/ld: bitfont.c:(.text+0x325): undefined reference to `glutAddMenuEntry'
/usr/bin/ld: bitfont.c:(.text+0x336): undefined reference to `glutAddMenuEntry'
/usr/bin/ld: bitfont.c:(.text+0x342): undefined reference to `glutCreateMenu'
/usr/bin/ld: bitfont.c:(.text+0x356): undefined reference to `glutAddMenuEntry'
/usr/bin/ld: bitfont.c:(.text+0x367): undefined reference to `glutAddMenuEntry'
/usr/bin/ld: bitfont.c:(.text+0x378): undefined reference to `glutAddMenuEntry'
/usr/bin/ld: bitfont.c:(.text+0x384): undefined reference to `glutCreateMenu'
/usr/bin/ld: bitfont.c:(.text+0x395): undefined reference to `glutAddMenuEntry'
/usr/bin/ld: bitfont.c:(.text+0x3a6): undefined reference to `glutAddMenuEntry'
/usr/bin/ld: bitfont.c:(.text+0x3b7): undefined reference to `glutAddMenuEntry'
/usr/bin/ld: bitfont.c:(.text+0x3c8): undefined reference to `glutAddSubMenu'
/usr/bin/ld: bitfont.c:(.text+0x3d9): undefined reference to `glutAddSubMenu'
/usr/bin/ld: bitfont.c:(.text+0x3e3): undefined reference to `glutAttachMenu'
/usr/bin/ld: bitfont.c:(.text+0x3e8): undefined reference to `glutMainLoop'
/usr/bin/ld: /tmp/cc7l7v1G.o:(.data.rel+0x0): undefined reference to `glutBitmapTimesRoman24'
/usr/bin/ld: /tmp/cc7l7v1G.o:(.data.rel+0x10): undefined reference to `glutBitmap9By15'
/usr/bin/ld: /tmp/cc7l7v1G.o:(.data.rel+0x18): undefined reference to `glutBitmapTimesRoman10'
/usr/bin/ld: /tmp/cc7l7v1G.o:(.data.rel+0x20): undefined reference to `glutBitmapTimesRoman24'
collect2: error: ld returned 1 exit status```