2013-10-24 57 views
7

問題:無論Qt Creator 2.8.1中選擇了調試還是發佈,CONFIG(debug,debug | release)和CONFIG(release,deubg | release) Linux操作系統。Qt Creator CONFIG(調試,釋放)開關不起作用

我的Qt Creator中的應用(股票 - 默認爲新項目)的配置:

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變量仍見調試和發佈配置。

我在做什麼錯?

+0

也許試着運行'qmake CONFIG- = Debug'進行發佈,'qmake CONFIG- = Release'進行調試 – dvvrd

+0

正如你在第一個代碼引用中看到的那樣。 – killdaclick

+0

不,我不會。我看到'CONFIG + = debug',而不是'CONFIG- = debug' – dvvrd

回答

18

Qmake是瘋了,這是唯一可行的解​​釋。整個發佈/調試在配置中多次聞起來像是一箇舊的設計錯誤,在它遲到之前從未解決,並且已經編寫了太多的配置。記住make中的選項卡?老兄有15個用戶,所以他從來沒有修復壞的決定。

無論如何。

我在Qt 4.8.4.1上看到了Linux上的相同問題。

這裏是解決方案:刪除大括號前的換行符。

從字面上看,這個工程:

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方面。

+1

謝謝!這個bug也存在於windows上 –

+1

Windows上的問題,Qt 5.3.1,Qt Creator 3.1.2 –

+0

將Qt 5.6添加到該列表中...... -______- –