Luis Lee 2022-03-10 10:42 采纳率: 53.8%
浏览 90
已结题

qt添加opengl库文件时候遇到的问题

*.pro文件下的代码

QT       += core gui
QT += opengl

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
LIBS += -LD:/Qt/Qt5.12.6/5.12.6/mingw73_32/lib -libfreeglut -opengl32
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    Bez.h \
    OpenGLWidget.h \
    mainwindow.h

FORMS += \
    mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

使用的库是freeglut,必要的静态库连接文件已加入

img

img

img

  • 写回答

5条回答 默认 最新

  • 封尘绝念丶 2022-03-10 10:55
    关注

    QtOpenGL里面没有glut拓展库,需要自己下载添加。如果用的是QtCreator,打开.pro文件,右键->添加库
    pro里有 QT += opengl 。
    如果还不行可能就是一些环境变量的问题了。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • togolife 2022-03-10 11:45
    关注

    LIBS += -LD:/Qt/Qt5.12.6/5.12.6/mingw73_32/lib -lfreeglut -lopengl32

    评论 编辑记录
  • 急速光粒 2022-03-10 14:01
    关注

    你这个lib配置的不对,你现在是:
    LIBS += -LD:/Qt/Qt5.12.6/5.12.6/mingw73_32/lib -libfreeglut -opengl32
    改成:
    LIBS += -LD:/Qt/Qt5.12.6/5.12.6/mingw73_32/lib -llibfreeglut -lopengl32
    你最好考过去。

    评论
  • 加油吧,小杜 2022-03-10 15:40
    关注

    lib配置有问题吧。以前我也配置过。你直接使用
    LIBS += D:/Qt/Qt5.12.6/5.12.6/mingw73_32/lib/libfreeglut.a

    评论
  • 赵4老师 2022-03-14 13:57
    关注

    -libfreeglut
    改为
    -lfreeglut

    评论 编辑记录
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 3月18日
  • 已采纳回答 3月10日
  • 创建了问题 3月10日

悬赏问题

  • ¥15 c++图Djikstra算法求最短路径
  • ¥15 Linux操作系统中的,管道通信问题
  • ¥15 ansible tower 卡住
  • ¥15 等间距平面螺旋天线方程式
  • ¥15 通过链接访问,显示514或不是私密连接
  • ¥100 系统自动弹窗,键盘一接上就会
  • ¥50 股票交易系统设计(sql语言)
  • ¥15 调制识别中这几个数据集的文献分别是什么?
  • ¥15 使用c语言对日志文件处理
  • ¥15 请大家看看报错原因,为啥会这样