我正在尝试在我的 mac 操作系统上安装 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)后,进展顺利。