jspooner
jspooner

Reputation: 11315

Install therubyracer on OSX

I have a fresh install of ruby 2.1.1, a clean set of gem and I reinstalled V8 with homebrew but I get this 'unrecognized command line option' error.

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

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) 

Upvotes: 0

Views: 1072

Answers (3)

equivalent8
equivalent8

Reputation: 14227

if Ubuntu users having this situation (e.g.: on a 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 solution:

sudo apt-get install build-essential g++ 

Upvotes: 2

Anas Alkhatib
Anas Alkhatib

Reputation: 1150

Changing the symbolic link of g++ and gcc worked for me on Mac OS 10.10.

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

Upvotes: 0

jspooner
jspooner

Reputation: 11315

I had to run 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

Upvotes: 0

Related Questions