在以下 C 代码中,该代码在教程中完美运行,返回:
01.c:(.text+0x25): undefined reference to `glutInit'
/sbin/ld: 01.c:(.text+0x34): undefined reference to `glutCreateWindow'
/sbin/ld: 01.c:(.text+0x43): undefined reference to `glutDisplayFunc'
/sbin/ld: 01.c:(.text+0x48): undefined reference to `glutMainLoop'
collect2: error: ld returned 1 exit status
#include <GL/glu.h>
#include <GL/glut.h>
void Draw() {
}
int main(int C, char *V[]) {
glutInit(&C, V);
glutCreateWindow("Basic OpenGL Program");
glutDisplayFunc(Draw);
glutMainLoop();
}
我尝试将它们复制到同一目录中,使用 -lc,使用 -L 和 gcc,使用 clang,ll 但仍然没有。
二手
clang 01.c -lGL -lGLU -lglut -o 01