[英]Build error in Qt Creator in release but not in debug
I'm working with Qt 5.15.2 in Qt Creator 6.0.2.我正在使用 Qt Creator 6.0.2 中的 Qt 5.15.2。 I have a program that uses a .lib file which was built in both debug (_ITERATOR_DEBUG_LEVEL = 0) and release (_ITERATOR_DEBUG_LEVEL = 2) versions.
我有一个使用 .lib 文件的程序,该文件是在调试(_ITERATOR_DEBUG_LEVEL = 0)和发布(_ITERATOR_DEBUG_LEVEL = 2)版本中构建的。 I can build the debug version of my program with no problems, but when I try to build the release I get this error:
我可以毫无问题地构建我的程序的调试版本,但是当我尝试构建版本时,我得到了这个错误:
LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in button.obj
LNK2038:检测到“_ITERATOR_DEBUG_LEVEL”不匹配:值“2”与 button.obj 中的值“0”不匹配
I also get我也得到
LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DyamicRelease' in button.obj
LNK2038:检测到“RuntimeLibrary”不匹配:值“MDd_DynamicDebug”与 button.obj 中的值“MD_DynamicRelease”不匹配
I understand my .obj files are somehow linked to ITERATOR_DEBUG_LEVEL = 0 and MDd, but I don't know how to change these parameters on the Qt project.我知道我的 .obj 文件以某种方式链接到 ITERATOR_DEBUG_LEVEL = 0 和 MDd,但我不知道如何在 Qt 项目中更改这些参数。
Here's the .pro file:这是 .pro 文件:
QT += core gui qml
QT += serialport
QT += multimedia
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += console
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
SOURCES += \
button.cpp \
checkbox.cpp \
combolist.cpp \
controlpanel.cpp \
expressionevaluator.cpp \
filter.cpp \
globals.cpp \
logicaloperator.cpp \
main.cpp \
mainwindow.cpp \
neurobit.cpp \
numericdisplay.cpp \
oscilloscope.cpp \
pnwiz.cpp \
pnwiz_devicethread.cpp \
pnwiz_ui.cpp \
pnwizconfigwindow.cpp \
pnwizconnectionmenu.cpp \
pnwizelectrocapmenu.cpp \
score.cpp \
shadow.cpp \
shadowpanel.cpp \
shadowvolume.cpp \
shadowwindow.cpp \
threshold.cpp \
thresholdbar.cpp \
timetransform.cpp \
variablefilter.cpp
HEADERS += \
button.h \
checkbox.h \
combolist.h \
controlpanel.h \
expressionevaluator.h \
filter.h \
globals.h \
logicaloperator.h \
mainwindow.h \
neurobit.h \
numericdisplay.h \
oscilloscope.h \
pnwiz.h \
pnwiz_devicethread.h \
pnwiz_ui.h \
pnwizconfigwindow.h \
pnwizconnectionmenu.h \
pnwizelectrocapmenu.h \
score.h \
shadow.h \
shadowpanel.h \
shadowvolume.h \
shadowwindow.h \
threshold.h \
thresholdbar.h \
timetransform.h \
variablefilter.h
FORMS += \
button.ui \
checkbox.ui \
combolist.ui \
controlpanel.ui \
mainwindow.ui \
numericdisplay.ui \
pnwiz_ui.ui \
pnwizconfigwindow.ui \
pnwizconnectionmenu.ui \
pnwizelectrocapmenu.ui \
shadowpanel.ui \
shadowwindow.ui \
threshold.ui \
thresholdbar.ui \
variablefilter.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
Images.qrc \
Sounds.qrc
LIBS += -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
unix|win32: LIBS += -L$$PWD/../Filtros01/Filtros01-Output/Products/x64Debug/ -lDSPFilters
INCLUDEPATH += $$PWD/DSPFilters_original/include
DEPENDPATH += $$PWD/DSPFilters_original/include
And here's the qmake call:这是 qmake 调用:
E:/Qt/5.15.2/msvc2019_64/bin/qmake.exe E:\C++\Qt\QWiz_4\QWiz_4.pro -spec win32-msvc "CONFIG+=qtquickcompiler" && E:/Qt/Tools/QtCreator/bin/jom/jom.exe qmake_all
I tried the solution proposed by Evgene and now I get a different error message:我尝试了 Evgene 提出的解决方案,现在我收到了不同的错误消息:
LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in button.obj
LNK2038:检测到“RuntimeLibrary”不匹配:值“MT_StaticRelease”与 button.obj 中的值“MD_DynamicRelease”不匹配
Any ideas on how this can be corrected?关于如何纠正这个问题的任何想法?
Ok, I was able to solve it by releasing the library in MD mode.好的,我可以通过在 MD 模式下发布库来解决它。 Now I can build in release mode.
现在我可以在发布模式下构建。 Thanks for the help!
谢谢您的帮助!
The problem is here:问题在这里:
unix|win32: LIBS += -L$$PWD/../Filtros01/Filtros01-Output/Products/x64Debug/ -lDSPFilters
As you can see, you always use x64Debug
libs build.如您所见,您始终使用
x64Debug
库构建。 Try something like this尝试这样的事情
CONFIG(debug, debug|release) {
unix|win32: LIBS += -L$$PWD/../Filtros01/Filtros01-Output/Products/x64Debug/
}
else {
unix|win32: LIBS += -L$$PWD/../Filtros01/Filtros01-Output/Products/x64Release/
}
unix|win32: LIBS += -lDSPFilters
Of course make sure the x64Release
path exists and replace it if needed.当然要确保
x64Release
路径存在并在需要时替换它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.