首页 > 解决方案 > 我不断收到错误“collect2.exe [错误] ld 返回 1 退出状态”,调试说明说我缺少安装了 openGl 的 openGl 函数

问题描述

#include <GL/glut.h>
void display()
{
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3f(1,0,0);
 glBegin(GL_POLYGON);
 glVertex2f(100,300);
 glVertex2f(100,100);
 glVertex2f(200,100);
 glVertex2f(200,300);
 glEnd();
 glFlush();
 glutSwapBuffers();
}

int main(int argc, char** argv)
{ 
 glutInit(&argc, argv);
 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
 glutInitWindowSize(640,640);
 glutCreateWindow("OpenGL");
 glutDisplayFunc(display);
 gluOrtho2D(0,640,0,640);
 glClearColor(0.5,0.7,0.5,0);
 glutMainLoop();
 return 0;
}

那是我运行 3DSage 制作的简单测试程序的代码。我使用 DEV C++ 安装了 OpenGl 和 Glut,并且我正在使用 C 编写 OpenGl 有人可以帮忙吗?'

Compile List:
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x23): undefined reference to `__glutInitWithExit'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x46): undefined reference to `__glutCreateWindowWithExit'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x68): undefined reference to `__glutCreateMenuWithExit'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x82): undefined reference to `__imp_glClear'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x9b): undefined reference to `__imp_glColor3f'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0xa9): undefined reference to `__imp_glBegin'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0xc2): undefined reference to `__imp_glVertex2f'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0xdb): undefined reference to `__imp_glVertex2f'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0xf4): undefined reference to `__imp_glVertex2f'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x10d): undefined reference to `__imp_glVertex2f'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x116): undefined reference to `__imp_glEnd'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x11f): undefined reference to `__imp_glFlush'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x126): undefined reference to `glutSwapBuffers'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x15b): undefined reference to `glutInitDisplayMode'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x16a): undefined reference to `glutInitWindowSize'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x182): undefined reference to `glutDisplayFunc'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x1b5): undefined reference to `gluOrtho2D'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x1d8): undefined reference to `__imp_glClearColor'
C:\Users\owner\Desktop\Neptune Engine\V1\Game.o Game.c:(.text+0x1df): undefined reference to `glutMainLoop'
C:\Users\owner\Desktop\Neptune Engine\V1\collect2.exe   [Error] ld returned 1 exit status
25      C:\Users\owner\Desktop\Neptune Engine\V1\Makefile.win   recipe for target 'NeptuneEngine.exe' failed

标签: copengl

解决方案


推荐阅读