【问题标题】:Install therubyracer on OSX在 OSX 上安装 therubyracer
【发布时间】:2014-10-05 20:45:40
【问题描述】:

我全新安装了 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) 

【问题讨论】:

    标签: therubyracer libv8


    【解决方案1】:

    如果 Ubuntu 用户遇到这种情况(例如:在 Ubuntu 虚拟机上)

    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++ 
    

    【讨论】:

      【解决方案2】:

      我必须运行 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
      

      【讨论】:

        【解决方案3】:

        在 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
        

        【讨论】:

          猜你喜欢
          • 2016-02-02
          • 2020-05-06
          • 2023-04-09
          • 1970-01-01
          • 1970-01-01
          • 2015-03-26
          • 1970-01-01
          • 2020-10-06
          • 2014-07-27
          相关资源
          最近更新 更多