因此,我使用qmake来创建程序,但是在调试和发布boost库之间总是出现以下冲突:
libboost_system-vc120-mt-s-1_58.lib(error_code.obj):-1: error: LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
我想使它自动化,以便从Qt Creator中选择调试或发布就足以创建正确的版本。我看到了其他解决方案,例如这里的解决方案,但这是行不通的。调用以下命令进行调试和发布时,可以看到它不起作用的原因:
message($$CONFIG)
这将打印qmake的配置。结果如下:
发布:
lex yacc调试异常Depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_offcremental_off windows qt warn_on release link_prl增量平面precompile_header autogen_precompile_source debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe版本32版本
对于调试:
lex yacc调试异常Depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_offcremental_off Windows qt warn_on发布link_prl增量平面precompile_header autogen_precompile_source debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe qpa inti_ti c ++ 11 ++
请注意,它们都包含调试和发布...,我想知道为什么...
我想指出的是,我从源代码编译了这个Qt版本。但是当我这样做的时候,没有什么奇怪的东西。我使用以下命令对其进行编译(配置然后使用简单的nmake进行编译):
configure -debug-and-release -opensource -platform win32-msvc2013 -opengl desktop -static -nomake examples -nomake tests
我debug:CONFIG-=release
在make文件中添加了命令:,从而尝试了一种乏味的解决方案,但是当我选择从Qt Creator发布时,它将导致发布版本以30 MB大小而不是14 MB的大小进行调试。
我的qmake文件是一个典型的文件。以下是可能与该问题有关的部分。其他部分只是添加文件,库和路径:
QMAKE_CFLAGS += /MT
QT += core gui
unix:QMAKE_CXXFLAGS += -std=c++11
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyProg
TEMPLATE = app
那么为什么会发生这个问题呢?为什么要调试或发布调试并发布?如何区分它们?
请询问您是否需要其他信息。
答案是我认为在Qt project org faq 355中
如果您始终接受Qt Creator建议的名称,则可以在pro文件中使用以下简单解决方案,以我为例(Qt 5.5),它们适用于Linux,Mac和Windows:
# to distinguish between debug and release executable as target
# we define the variables releaseExec and debugExec
# this only works if the $$OUT_PWD has "Release" in its name
BDIR = $$OUT_PWD
BDIR_STRIPPED = $$replace(BDIR,Release,)
equals (BDIR,$$BDIR_STRIPPED): CONFIG+= debugExec
else: CONFIG+= releaseExec
我们使用了变量,releaseExec
并debugExec
避免了与Qt CONFIG变量的名称冲突。
现在,您可以使用switch语句:
releaseExec: warning ("this is a release build")
debugExec: warning ("this is a debug build")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句