Qt Creator调试工作正常,但无法编译发行版
我在基于Qt 5.11.2(MSVC 2015,32位)的QtCreator 4.7.2中生成发布文件夹时遇到一些问题。我的程序在调试版本中运行良好,但当我将构建更改为发布版本时,会出现编译器错误 我在我的应用程序中使用QCustomPlot库,但在发布版本中它并不喜欢Qt Creator调试工作正常,但无法编译发行版,qt,qt-creator,Qt,Qt Creator,我在基于Qt 5.11.2(MSVC 2015,32位)的QtCreator 4.7.2中生成发布文件夹时遇到一些问题。我的程序在调试版本中运行良好,但当我将构建更改为发布版本时,会出现编译器错误 我在我的应用程序中使用QCustomPlot库,但在发布版本中它并不喜欢 integerPart > 0 ? QString::number(integerPart)+QLatin1String(" ") : QLatin1String("") 这给我带来了一个C2446:':':没有从'QL
integerPart > 0 ? QString::number(integerPart)+QLatin1String(" ") : QLatin1String("")
这给我带来了一个C2446:':':没有从'QLatin1String'转换为'QStringBuilder'
所以我把测试线换成了
integerPart > 0 ? "" : ""
因此编译器不再抛出错误,但现在我得到一个LNK1158:无法运行'rc.exe'
我试图清理构建并运行qmake,但链接器错误并没有消失。你知道是什么导致了这些问题吗?我只是从调试切换到发布
编辑:
#-------------------------------------------------
#
# Project created by QtCreator 2018-11-09T09:59:59
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
TARGET = PlotterApp
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as 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
DEFINES += QT_USE_QSTRINGBUILDER
# You can also make your code fail to compile if you use 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
CONFIG += c++11
QT += serialport
SOURCES += \
main.cpp \
mainwindow.cpp \
serialporthandler.cpp \
qcustomplot.cpp \
parameterobject.cpp
HEADERS += \
mainwindow.h \
serialporthandler.h \
qcustomplot.h \
parameterobject.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
转到此文件夹
C:\ProgramFiles(x86)\Windows Kits\10\bin\10.0.17763.0\x86
然后将rc.exe和rcdll.dll复制到以下文件夹中
X64
C:\ProgramFiles(x86)\Microsoft Visual Studio 14.0\VC\bin\x86\u amd64
X86
C:\ProgramFiles(x86)\Microsoft Visual Studio 14.0\VC\bin
为什么要使用
QLatin1String
而不仅仅是“
QString
有一个forconst char*
好吧,我没有写这个,这是QCustomPlot库的一部分。嗯,这里是,也许这是相关的。QT\u USE\QSTRINGBUILDER
是否只能在发行版中定义?如果我理解正确,那么操作符+
将在调试中返回QString
,在发布版本中返回QStringBuilder
。另一方面,这篇文章是关于Qt4的,不知道它是否仍然适用。看起来编译器正在尝试将第二个QLatin1String(“”
)转换为QStringBuilder
。对于三元表达式,冒号前后的表达式必须是相同的类型。您是否尝试过将其替换为integerPart>0?QString::number(integerPart)+QString(“”):QString(“”)
?好的,integerPart>0?QString::number(integerPart)+QString(“”):QString(“”)零件已工作。现在仍然存在此链接器错误,但仅在relase中存在。没有说明链接器脚本有什么问题,我在编辑中发布了上面的Scrut。嗯,好的,我这样做了,但仍然有相同的错误。@Hanspetersoft您的构建选项是什么?X64版本或X86版本?高张铁男, 是X86release@HansPeterLoft更新答案。