undefined reference to `__imp_glRotatef‘

解决Qt中OpenGL链接错误:undefined reference to `__imp_glRotatef'
在使用Qt进行OpenGL编程时遇到undefined reference to `__imp_glRotatef'的问题。这通常是由于缺少库链接导致的。通过在.pro文件中添加`LIBS+=-lopengl32`和`LIBS+=-lGLU32`两行,可以成功解决这个问题,确保Qt项目正确链接到所需的OpenGL库。

测试OpenGL的代码,出现undefined reference to `__imp_glRotatef'

Qt中已经有了OpenGL的东西,和以前已经不一样了。竟然还有这样的错误,很奇怪。

经过一番搜索,发现了解决办法,在pro文件中加入下面两行。

LIBS += -lopengl32
LIBS += -lGLU32

g++ -std=c++17 -Wall -Wextra -g -Iinclude -c -MMD src/main.cpp -o src/main.o g++ -std=c++17 -Wall -Wextra -g -Iinclude -o output\main.exe src/main.o -Llib -lglad -lglfw3dll d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: src/main.o: in function `glutInit_ATEXIT_HACK': D:\opengl\GC/include/GL/freeglut_std.h:637: undefined reference to `_imp____glutInitWithExit@12' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: src/main.o: in function `glutCreateWindow_ATEXIT_HACK': D:\opengl\GC/include/GL/freeglut_std.h:639: undefined reference to `_imp____glutCreateWindowWithExit@8' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: src/main.o: in function `glutCreateMenu_ATEXIT_HACK': D:\opengl\GC/include/GL/freeglut_std.h:641: undefined reference to `_imp____glutCreateMenuWithExit@8' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: src/main.o: in function `Z9myDrawingv': D:\opengl\GC/src/main.cpp:9: undefined reference to `glClearColor@16' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\opengl\GC/src/main.cpp:10: undefined reference to `glClear@4' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\opengl\GC/src/main.cpp:13: undefined reference to `glRotatef@16' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\opengl\GC/src/main.cpp:14: undefined reference to `_imp__glutWireTeapot@8' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\opengl\GC/src/main.cpp:17: undefined reference to `glFlush@0' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: src/main.o: in function `main': D:\opengl\GC/src/main.cpp:24: undefined reference to `_imp__glutInitDisplayMode@4' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\opengl\GC/src/main.cpp:28: undefined reference to `_imp__glutDisplayFunc@4' d:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: D:\opengl\GC/src/main.cpp:33: undefined reference to `_imp__glutMainLoop@0' collect2.exe: error: ld returned 1 exit status Makefile:78: recipe for target 'main.exe' failed
最新发布
06-22
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值