问题:无论在 Qt Creator 2.8.1 for Linux 中选择调试还是发布,CONFIG(debug,debug|release) 和 CONFIG(release,deubg|release) 总是被评估。
我在 Qt Creator 应用程序中的配置(stock - 新项目的默认设置):
Projects->Build Settings->Debug Build Steps:
qmake build configuration: Debug
Effective qmake call: qmake2 proj.pro -r -spec linux-gnueabi-oe-g++ CONFIG+=debug
Projects->Build Settings->Release Build Steps:
qmake build configuration: Release
Effective qmake call: qmake2 proj.pro -r -spec linux-gnueabi-oe-g++
我在 proj.pro 中的配置:
message(Variable CONFIG:)
message($$CONFIG)
CONFIG(debug,debug|release)
{
message(Debug build)
}
CONFIG(release,debug|release)
{
message(Release build)
}
调试控制台输出:
Project MESSAGE: Variable CONFIG:
Project MESSAGE: lex yacc warn_on debug uic resources warn_on release incremental link_prl no_mocdepend release stl qt_no_framework debug console
Project MESSAGE: Debug build
Project MESSAGE: Release build
发布控制台输出:
Project MESSAGE: Variable CONFIG:
Project MESSAGE: lex yacc warn_on uic resources warn_on release incremental link_prl no_mocdepend release stl qt_no_framework console
Project MESSAGE: Debug build
Project MESSAGE: Release build
在 Windows 7 下,我没有遇到此类 .pro 配置的任何问题,并且运行良好。 我绝望了,修改了.pro文件:
CONFIG = test
message(Variable CONFIG:)
message($$CONFIG)
CONFIG(debug,debug|release)
{
message(Debug build)
}
CONFIG(release,debug|release)
{
message(Release build)
}
我对输出感到惊讶:
Project MESSAGE: Variable CONFIG:
Project MESSAGE: test
Project MESSAGE: Debug build
Project MESSAGE: Release build
所以即使我完全清理 CONFIG 变量,它仍然可以看到调试和发布配置。
我做错了什么?
最佳答案
Qmake 疯了,这是唯一可行的解释。整个发布/调试在配置中多次闻起来像一个旧的设计错误,在它为时已晚并且已经编写了太多配置之前从未解决过。还记得 make 中的标签吗? Dude 有大约 15 个用户,所以他从不修正错误的决定。
无论如何。
我在 Linux 和 Qt 4.8.4.1 上看到了同样的问题。
这里是解决方案:删除大括号前的换行符。
从字面上看,这是可行的:
CONFIG(release, debug|release) {
message(Release)
}
CONFIG(debug, debug|release) {
message(Debug)
}
虽然这不是:
CONFIG(release, debug|release)
{
message(Release)
}
CONFIG(debug, debug|release)
{
message(Debug)
}
我怀疑这是一些 qmake 版本中的解析错误,可能仅在 linux 端。
关于linux - Qt Creator CONFIG(调试、发布)开关不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19562591/