如何检测Qt Creator的目标(调试/发布)(Visual Studio)

量子物理学家

因此,我使用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

我们使用了变量,releaseExecdebugExec避免了与Qt CONFIG变量的名称冲突。

现在,您可以使用switch语句:

releaseExec: warning ("this is a release build")
debugExec: warning ("this is a debug build")

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Visual Studio调试器如何检测功能调用?

使用CMake时在Visual Studio中检测构建类型(调试/发布)

如何在CMake for Visual Studio中获取当前配置(发布/调试)

在发布模式下处于活动状态时,如何在Visual Studio中以调试模式关闭DocFX?

如何自动化Visual Studio发布和附加调试器?

(Visual Studio) 如何检测未使用的导入?

Visual Studio:复制安装文件夹并将其设置为由Qt Creator自动检测

发布目标之前的 Visual Studio 未触发

在Visual Studio扩展中,如何检测调试器何时继续

Visual Studio扩展项目:如何更改目标Visual Studio版本?

Visual Studio 2019 调试嵌入式目标。如何强制 VS 不将其视为 Windows 可执行文件

Visual Studio发布使用调试模式而不是发布

如何在 Visual Studio 2019 .net5.0 上允许发布和调试不安全代码

如何使用Visual Studio代码调试Django

Visual Studio调试优化如何工作?

如何在visual studio中调试python

Qt Creator CONFIG(调试,发布)开关不起作用

Visual Studio中的“发布”如何工作?

Visual Studio 2013如何检测缓冲区溢出

如何以编程方式检测Visual Studio版本?

如何使用Android Studio在发布模式下调试Android App

缺少Visual Studio Web应用程序发布目标

Visual Studio中缺少Azure功能应用发布目标

Visual Studio中的多个调试和发布配置选项

find_package用于Visual Studio的调试和发布

如何在Visual Studio Code中使用Qt?

如何在Visual Studio 2017中使用Qt库?

如何使用Qt的应用清单生成Visual Studio项目?

如何将Qt库添加到Visual Studio