在 mac os 上安装 mechainze gem 时出现奇怪的错误

weird error when installing mechainze gem on mac os

我正在尝试在我的 mac os 上安装 mechainze gem,但是当我输入 gem install mechanize 时,几秒钟后,它弹出输出:

Building native extensions.  This could take a while...
ERROR:  Error installing mechanize:
    ERROR: Failed to build gem native extension.

    /Users/Tim/.rvm/rubies/ruby-1.9.3-p545/bin/ruby extconf.rb
checking for main() in -lstdc++... yes
checking for ruby/encoding.h... yes
creating Makefile

make  clean

make
compiling unf.cc
g++: error: unrecognized command line option '-Wshorten-64-to-32'
make: *** [unf.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/Tim/.rvm/gems/ruby-1.9.3-p545@global/gems/unf_ext-0.0.6 for inspection.
Results logged to /Users/Tim/.rvm/gems/ruby-1.9.3-p545@global/extensions/x86_64-darwin-12/1.9.1/unf_ext-0.0.6/gem_make.out

我不知道为什么会这样,有没有人愿意帮忙?

谢谢!

PS:我发现其实很久以前我把默认编译器设置为g++而不是clang。这重要吗?

其实这确实是我将默认编译器切换为gcc4.7造成的。我切换回去后(命令:sudo port select --set gcc llvm-gcc42),很顺利