2011-07-20 97 views
10

我在努力安裝RedCloth的寶石。當我鍵入有沒有辦法改變一個gem的gcc編譯選項?

gem install RedCloth 

我得到:

[…] 
ragel/redcloth_attributes.c.rl: In function ‘redcloth_attribute_parser’: 
ragel/redcloth_attributes.c.rl:26:11: error: variable ‘act’ set but not used [-Werror=unused-but-set-variable] 
cc1: all warnings being treated as errors 

make: *** [redcloth_attributes.o] Error 1 
[…] 

的原因是傳遞給GCC在RedCloth寶石的extconf.rb的-Werror編譯選項:

require 'mkmf' 
CONFIG['warnflags'].gsub!(/-Wshorten-64-to-32/, '') if CONFIG['warnflags'] 
$CFLAGS << ' -O0 -Wall -Werror' if CONFIG['CC'] =~ /gcc/ 
[…] 

問題當我從文件中刪除-Werror選項時,它會在下次啓動「gem install」命令時自動重新出現。

如何永久取消-Werror選項?


另一種選擇是降級到4.5.2的gcc,但它不是在我的Fedora 15

的信息庫和我寧願避免從源代碼編譯它...

任何幫助非常感謝。

回答

21

有同樣的問題,在這裏是解決方案:

#gem install RedCloth -- --with-cflags=\"-O2 -pipe -march=native -Wno-unused-but-set-variable\" 

你,如果你有一個以上的參數,以逃避報價。

+1

甜,它的作品!有沒有辦法將它放在Gemfile中,以便項目中的其他人不必分別安裝gem? –

+0

我有'gem install rbczmq'類似的問題引起的「歸因棄用」警告;但傳入'-Wno-deprecated-declarations'不起作用。我不得不更新實際的C頭文件。 – motivic

9

如果您使用bundler,以下工作:

bundle config build.RedCloth --with-cflags=\"-O2 -pipe -march=native -Wno-unused-but-set-variable\" 
+0

是的,這工作的另一個缺少'linux/inet_diag.h'的gem:'bundle config build.raindrops --with-cflags = \「 - I /.../ kernel-xyz /.../ usr /包括\「' – l0b0

相關問題