2012-03-15 63 views
9

我試圖在調試會話中得到ZBar。我可以這樣做,但我無法關閉優化器,因此我的調試會話意外跳轉,Eclipse Indigo中的許多變量都標記爲optimized-out。我在Ubuntu上運行。無法關閉gcc優化器,automake中的Makefile

我曾嘗試在Makefiles中的任何gcc調用中儘可能地加上-O0,因爲最後的-O是代理的。我用-Q --help =優化,以找到要尋找的東西,但它的輸出是一個有點奇怪:

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./include -I./zbar -I./include -O0 -O0 -Q --help=optimizers -Wall -Wno-parentheses -O0 -g -O0 -Q --help=optimizers -MT zbar/zbar_libzbar_la-config.lo -MD -MP -MF zbar/.deps/zbar_libzbar_la-config.Tpo -c zbar/config.c -fPIC -DPIC -o zbar/.libs/zbar_libzbar_la-config.o 
The following options control optimizations: 
make[1]: *** [zbar/zbar_libzbar_la-config.lo] Error 1 
    -O<number>       
make: *** [all] Error 2 
    -Ofast        
    -Os        
    -falign-functions     [disabled] 
    -falign-jumps      [disabled] 
    -falign-labels     [disabled] 
    -falign-loops      [disabled] 
    -fasynchronous-unwind-tables  [enabled] 
    -fbranch-count-reg    [enabled] 
    -fbranch-probabilities   [disabled] 
    -fbranch-target-load-optimize  [disabled] 
    -fbranch-target-load-optimize2 [disabled] 
    -fbtr-bb-exclusive    [disabled] 
    -fcaller-saves     [disabled] 
    -fcombine-stack-adjustments  [disabled] 
    -fcommon       [enabled] 
    -fcompare-elim     [disabled] 

etc... 

很顯然,我已經把-O0在幾個地方。我對ZBar使用的automake沒有任何經驗。我試圖避免從頭開始製作自己的Makefile,有沒有關於在哪裏尋找禁用優化器的建議?我已經搜索了Makefiles的所有-O的和任何-f的優化;我找不到。在Makefile修改嘗試完成後,項目被清理了。

回答

18

禁用優化可以在運行configure或運行make時輕鬆完成。無論是

configure CFLAGS='-g -O0' CXXFLAGS='-g -O0' 

make CFLAGS='-g -O0' CXXFLAGS='-g -O0' clean all 

應該做你想要什麼。如果您在配置期間設置了CFLAGS/CXXFLAGS,則這些值將用於所有make不會覆蓋它們的調用,而在製作時設置它們是一次性處理。

+2

都沒有效果。請注意,我不是代碼的作者,而只是試圖完成算法分析。將-O0與make調用相結合,將-O0置於任何其他標誌之前以啓用優化,從而使其無效。我沒有看到在成千上萬行的Makefile代碼中設置了任何優化標誌...... – vlad417 2012-03-15 18:04:05

+0

CFLAGS應該是makefile中COMPILE中設置的最後一項,所以除非包維護者重寫了您設置CFLAGS的嘗試應該報告爲一個錯誤)你的設置應該是最後的。如果你做了「CFLAGS = -this-option-is-an-error」,編譯過程中是否出現這個選項? – 2012-03-15 18:10:59

+0

當我添加錯誤標誌時,出現:'gcc:error:unrecognized option'-this-option-is-an-error'' – vlad417 2012-03-15 18:16:32