解决“error: undefined reference to `_imp__gl*@8'”

本文介绍了解决Qt新版本中缺失基本GL库导致的错误的方法。通过在.pro文件中添加特定的库链接指令,可以有效避免如“error:undefined referenceto `_imp__glBindTexture@8'”等错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

因为在新版本中的qt已经没有一些gl的基本库了,使用的时候会报错:

如“error: undefined reference to `_imp__glBindTexture@8'”

解决办法很简单,只需要在.pro文件中添加以下两行即可:

LIBS += -lopengl32\
         -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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值