如何检测Qt Creator的目标(调试/发布)(Visual Studio) [英] How to detect Qt Creator's target (debug/release) (Visual Studio)
问题描述
所以我用的qmake创建我的计划,但我的总是的有我的调试之间的冲突和释放Boost库的消息:
libboost_system-vc120-mt-s-1_58.lib(error_code.obj): - 1:错误:LNK2038:检测到_ITERATOR_DEBUG_LEVEL的不匹配:值'0'匹配值'2'in main.obj
我想让这个自动化其中选择从Qt Creator调试或发布足以创建正确的版本。我看到其他解决方案,例如这里 ,但这不工作。调用以下命令调试和发布时,可以看到它不工作的原因:
message CONFIG)
这将打印qmake的配置。结果如下:
对于发布:
lex yacc调试异常depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off窗户QT warn_on发布link_prl增量持平precompile_header autogen_precompile_source debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe C ++ 11的调试静态RTTI no_plugin_manifest QPA的Win32 MSVC copy_dir_files发布
块引用>
有关调试:
的lex yacc的调试异常depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off窗户QT warn_on发布link_prl增量持平precompile_header autogen_precompile_source debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe C ++ 11的调试静态RTTI no_plugin_manifest QPA的Win32 MSVC copy_dir_files
块引用>
注意两个的包含调试并释放...我想知道为什么...
我想指出,我从源代码编译这个Qt版本。但是当我这样做时,没有奇怪的东西。我用下面的命令编译它(配置然后用简单的NMAKE编译):
配置-debug和释放-opensource -platform win32-msvc2013 -opengl desktop -static -nomake示例-nomake tests
通过添加命令:
调试:CONFIG- =发布
在我的make文件,但将导致发行版本成为调试与30 MB的大小,而不是14 MB,当我选择从Qt Creator发布。
我的qmake文件是一个典型的文件。以下是可能与问题有关的部分。其他部分只是添加文件和库和路径:
QMAKE_CFLAGS + = / MT
QT + = core gui
unix:QMAKE_CXXFLAGS + = -std = c ++ 11
greaterThan(QT_MAJOR_VERSION,4):QT + = widgets
TARGET = MyProg
TEMPLATE = app
那么为什么会出现这个问题?为什么我的调试或发布调试和发布?
解决方案
请问您是否需要任何其他信息。 / DIV>
答案是我觉得在 Qt项目组织常见问题解答355
如果你总是接受该名称Qt Creator的建议为你的构建,你可以用下面简单的解决方案在你,在我的情况(QT 5.5)的作品在Linux,Mac和Windows专业版文件:
#区分调试和发布可执行文件作为目标
#我们定义变量releaseExec和debugExec
#this only works如果$$ OUT_PWD在其名称中有Release
BDIR = $$ OUT_PWD
BDIR_STRIPPED = $$ replace(BDIR,Release,)
equals(BDIR,$$ BDIR_STRIPPED):CONFIG + = debugExec
else:CONFIG + = releaseExec
c $ c> releaseExec 和
debugExec
以避免与Qt CONFIG变量发生名称冲突。
现在可以使用switch语句:
releaseExec:warning(this is a release build)
debugExec :warning(this is a debug build)
So I use qmake to create my program, but I'm always having a conflict between my debug and release boost libraries with the message:
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
I would like to make this automated, in such a way where choosing debug or release from Qt Creator suffices to create the correct version. I saw other solutions like the one here, but that doesn't work. The reason why it doesn't work can be seen when calling the following command for both debug and release:
message($$CONFIG)
which will print the configuration of qmake. The results are the following:
For release:
lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off windows qt warn_on release link_prl incremental flat precompile_header autogen_precompile_source debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe c++11 debug static rtti no_plugin_manifest qpa win32 msvc copy_dir_files release
For Debug:
lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off windows qt warn_on release link_prl incremental flat precompile_header autogen_precompile_source debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe c++11 debug static rtti no_plugin_manifest qpa win32 msvc copy_dir_files
Notice that both contain debug and release... and I'm wondering why...
I would like to point out that I compiled this Qt version from source. But there was no weird stuff when I did that. I used the following command to compile it (configure then compile with simple nmake):
configure -debug-and-release -opensource -platform win32-msvc2013 -opengl desktop -static -nomake examples -nomake tests
I tried a dull solution by adding the command:
debug:CONFIG-=release
in my make file, but that will cause the release version to become debug with 30 MB size instead of 14 MB when I choose release from Qt Creator.My qmake file is a typical one. The following is the part that could have anything to do with the problem. The other parts are just adding files and libraries and paths:
QMAKE_CFLAGS += /MT QT += core gui unix:QMAKE_CXXFLAGS += -std=c++11 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = MyProg TEMPLATE = app
So why is this problem happening? Why are my debug or release a debug and release? How can I distinguish between them?
Please ask if you require any additional information.
解决方案The answer is I think in Qt project org faq 355
If you always accept the name Qt Creator suggests for your build you can use the following simple solution in your pro files that in my case (Qt 5.5) works for Linux, Mac and 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
We used the variables
releaseExec
anddebugExec
to avoid name collisions with Qt CONFIG variables.You can now use the switch statements:
releaseExec: warning ("this is a release build") debugExec: warning ("this is a debug build")
这篇关于如何检测Qt Creator的目标(调试/发布)(Visual Studio)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文