0

我全新安装了 ruby​​ 2.1.1,一套干净的 gem,我用自制软件重新安装了 V8,但我收到了这个“无法识别的命令行选项”错误。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/jspooner/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb 
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling accessor.cc
g++: error: unrecognized command line option '-rdynamic'
make: *** [accessor.o] Error 1

make failed, exit code 2

g++ 版本

g++ -v 
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.8.3/libexec/gcc/x86_64-apple-darwin13.2.0/4.8.3/lto-wrapper
Target: x86_64-apple-darwin13.2.0
Configured with: ../configure --build=x86_64-apple-darwin13.2.0 --prefix=/usr/local/Cellar/gcc/4.8.3 --enable-languages=c,c++,objc,obj-c++,fortran --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.8.3 (GCC) 
4

3 回答 3

1

如果 Ubuntu 用户有这种情况(例如:在 Ubuntu VM 上)

gem install therubyracer -v '0.11.4'                                                                                    
\Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
        ERROR: Failed to build gem native extension.

    /home/deploy/.rbenv/versions/2.0.0-p247/bin/ruby extconf.rb
checking for main() in -lpthread... yes
creating Makefile

make "DESTDIR="
compiling accessor.cc
make: g++: Command not found
make: *** [accessor.o] Error 127


Gem files will remain installed in /home/deploy/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/therubyracer-0.11.4 for inspection.
Results logged to /home/deploy/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/therubyracer-0.11.4/ext/v8/gem_make.out

Ubuntu解决方案:

sudo apt-get install build-essential g++ 
于 2015-03-27T14:53:37.053 回答
0

在 Mac OS 10.10 上更改 g++ 和 gcc 的符号链接对我有用。

ls -al /opt/local/bin/gcc
ls -al /opt/local/bin/g++
sudo rm /opt/local/bin/gcc 
sudo rm /opt/local/bin/g++
sudo ln -s /usr/bin/llvm-gcc /opt/local/bin/gcc
sudo ln -s /usr/bin/llvm-g++ /opt/local/bin/g++
gem install therubyracer -v '0.12.1'
sudo rm /opt/local/bin/g++
sudo rm /opt/local/bin/gcc
sudo ln -s /opt/local/bin/g++-mp-4.9 /opt/local/bin/g++
sudo ln -s /opt/local/bin/gcc-mp-4.9 /opt/local/bin/gcc
于 2015-03-16T16:05:05.080 回答
0

我不得不运行 brew update gcc。

 brew upgrade gcc
==> Upgrading 1 outdated package, with result:
gcc 4.9.1
==> Upgrading gcc
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gcc-4.9.1.mavericks.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring gcc-4.9.1.mavericks.bottle.2.tar.gz
==> Caveats
GCC has been built with multilib support. Notably, OpenMP may not work:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670
If you need OpenMP support you may want to
  brew reinstall gcc --without-multilib
==> Summary
  /usr/local/Cellar/gcc/4.9.1: 1152 files, 203M
于 2014-10-05T22:18:22.240 回答