C 中对 glutX 的未定义引用

问题描述 投票:0回答:1

在以下 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 但仍然没有。

c opengl glut undefined-reference
1个回答
0
投票

二手

clang 01.c -lGL -lGLU -lglut -o 01

© www.soinside.com 2019 - 2024. All rights reserved.