qt vc打包编译注意事项

  • Post author:
  • Post category:其他


项目配置中,选择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



版权声明:本文为scutedu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。