c - 我不断收到错误“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
解决方案
推荐阅读
- firebase - 多个流到 Firebase 文档而不进行处理
- angularjs - 在AngularJS中从另一个模块导入组件的最佳方法是什么?
- php - 是否可以重用带有变量的双引号字符串?
- react-native - 如何获取 Navigation AppContainer 的参数?
- json - 错过将 Json 映射到列表/数组的最后一步(颤振)
- excel - 使用 vbscript 从 Excel 列数据中选择随机值不起作用
- ios - iOS 广播上传扩展、框架和应用程序之间的通信
- sql - 行到列,具有复杂的 agg 函数,将计算字段转换为列
- python - 无法使用 pysftp 将文件夹上传到 Sftp
- arrays - 谷歌表格查询最大日期