qt vc打包编译注意事项

博客介绍了Qt项目配置相关内容。选择MSVC2015 32位版本进行编译,安装该编译器最快办法是装VS2015。针对编译报错找不到头文件给出修改方法,还提到用windeployqt工具复制依赖库到exe目录,拷贝msvc相关库,使程序能在无MSVC环境运行。

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

项目配置中,选择MSVC2015 32位版本,64位库有些不好找,32位比较保险,后期不麻烦

选这个编译器,要安装MSVC2015编译器,最快的办法就是安装VS2015.

编译报错,找不到头文件 ,修改如下

然后把用windeployqt + name.exe  工具把相关的依赖库复制到exe目录下,再把msvc相关的库拷贝到目录下。

 这样放到没有MSVC的环境中也能正常运行。代码如下

QT       += core gui

#[1] add serialport
QT += serialport serialbus
QT += sql

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

INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt/x86"

# 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 \
    myComboBox.cpp \
    modbusmng.cpp \
    bottommng.cpp \
    dialoginputpw.cpp \
    dialogchangepw.cpp \
    logmng.cpp

HEADERS += \
    mainwindow.h \
    myComboBox.h \
    modbusmng.h \
    fundef.h \
    bottommng.h \
    dialoginputpw.h \
    dialogchangepw.h \
    logmng.h

FORMS += \
    mainwindow.ui \
    dialoginputpw.ui \
    dialogchangepw.ui

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

DISTFILES += \
    helptf \
    readme

RESOURCES += \
    image.qrc

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值