Gcc 修复Mavericks上的Rubyracer/libv8(0.12.1)安装

Gcc 修复Mavericks上的Rubyracer/libv8(0.12.1)安装,gcc,rubygems,v8,therubyracer,libv8,Gcc,Rubygems,V8,Therubyracer,Libv8,好吧,我对这个已经束手无策了。也有一些类似的问题,但它们都提到了Rubyracer 0.10,他们大多得出结论,升级到0.12可以解决这个问题 我也有类似的问题,但是当我使用0.12时 类似问题 我在使用“标准”(xcode?)gcc以及自制的apple-gcc42和gcc时遇到问题。我已经尝试了——使用-system-v8和——不使用-system-v8,再次尝试,没有骰子 以下是一些日志: 从零开始… 尝试捆绑安装 安装libv8(3.16.14.3) Gem::Installer:

好吧,我对这个已经束手无策了。也有一些类似的问题,但它们都提到了Rubyracer 0.10,他们大多得出结论,升级到0.12可以解决这个问题

我也有类似的问题,但是当我使用0.12时

类似问题
我在使用“标准”(xcode?)gcc以及自制的apple-gcc42和gcc时遇到问题。我已经尝试了
——使用-system-v8
——不使用-system-v8
,再次尝试,没有骰子

以下是一些日志:

从零开始… 尝试捆绑安装
安装libv8(3.16.14.3)
Gem::Installer::ExtensionBuildError:错误:无法生成Gem本机扩展。
/Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
创建Makefile
为x64编译v8
使用python 2.7.5
配置为:--prefix=/Applications/Xcode.app/Contents/Developer/usr--gxx include dir=/usr/include/c++/4.2.1
找不到v8正式支持的编译器。
建议使用GCC v4.4或更高版本
使用编译器:g++
配置为:--prefix=/Applications/Xcode.app/Contents/Developer/usr--gxx include dir=/usr/include/c++/4.2.1
找不到v8正式支持的编译器。
建议使用GCC v4.4或更高版本
../src/cached powers.cc:136:18:错误:未使用的变量“kCachedPowersLength”[-Werror,-Wunused const variable]
静态常量int kCachedPower长度=数组大小(kCachedPower);
^
生成1个错误。
make[1]:***[/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached powers.o]错误1
make:**[x64.release]错误2
/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in‘block in verify_installation’:libv8安装不正确,应为二进制v8归档文件“/Users/chris/.rvm/gems/ruby-1.9.3”-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'不存在,但未找到它(libv8::Location::vendor::ArchiveNotFound)
来自/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:在'each'中
来自/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:在“验证安装”中
来自/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in'install!'
来自extconf.rb:7:in`'
GYP_发电机=制造\
build/gyp/gyp——生成器输出=“out”build/all.gyp\
-Ibuild/standalone.gypi——深度=\
-Dv8_目标_拱=x64\
-S.x64-Dv8_启用_回溯=1-Dv8_可以使用_vfp2_指令=true-Darm_fpu=vfpv2-Dv8_可以使用_vfp3_指令=true-Darm_fpu=vfpv3
CXX(target)/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
CXX(target)/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser\u lib/src/atomicops\u internal\u x86\u gcc.o
CXX(target)/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
CXX(target)/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum dtoa.o
CXX(target)/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached powers.o
Gem文件仍将安装在/Users/chris/.rvm/gems/ruby-1.9.3中-p448@website/gems/libv8-3.16.14.3进行检查。
结果记录到/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/gem_make.out
安装libv8(3.16.14.3)时出错,捆绑程序无法继续。
糟糕的时刻。 错误消息建议建议使用gcc 4.4+。我们可以做到

$ export CXX=/usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8 
$ export CPP=/usr/local/Cellar/gcc48/4.8.2/bin/cpp-4.8 
$ export CC=/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8 
$ which $CXX
/usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
$ which $CPP
/usr/local/Cellar/gcc48/4.8.2/bin/cpp-4.8
$ which $CC
/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8
$ bundle install
…
Installing libv8 (3.16.14.3) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb 
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Using compiler: /usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
g++-4.8: error: unrecognized command line option '-Wnewline-eof'
make[1]: *** [/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [x64.release] Error 2
/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
    build/gyp/gyp --generator-output="out" build/all.gyp \
                  -Ibuild/standalone.gypi --depth=. \
                  -Dv8_target_arch=x64 \
                  -S.x64  -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3
  CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o


Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/gem_make.out

An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.
$export CXX=/usr/local/ceral/gcc48/4.8.2/bin/g++-4.8
$export CPP=/usr/local/Cellar/gcc48/4.8.2/bin/CPP-4.8
$export CC=/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8
$CXX是哪个$CXX
/usr/local/Cell/gcc48/4.8.2/bin/g++-4.8
$CPP,哪个$CPP
/usr/local/Cell/gcc48/4.8.2/bin/cpp-4.8
$CC,哪一个$CC
/usr/local/Cell/gcc48/4.8.2/bin/gcc-4.8
$bundle安装
…
安装libv8(3.16.14.3)
Gem::Installer::ExtensionBuildError:错误:无法生成Gem本机扩展。
/Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
创建Makefile
为x64编译v8
使用python 2.7.5
使用编译器:/usr/local/ceral/gcc48/4.8.2/bin/g++-4.8
g++-4.8:错误:无法识别的命令行选项“-Wnewline eof”
make[1]:***[/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o]错误1
make:**[x64.release]错误2
/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in‘block in verify_installation’:libv8安装不正确,应为二进制v8归档文件“/Users/chris/.rvm/gems/ruby-1.9.3”-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'不存在,但未找到它(libv8::Location::vendor::ArchiveNotFound)
来自/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:在'each'中
来自/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:在“验证安装”中
来自/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in'install!'
来自extconf.rb:7:in`'
GYP_发电机=制造\
build/gyp/gyp——生成器输出=“out”build/all.gyp\
-Ibuild/standalone.gypi——深度=\
-Dv8_目标_拱=x64\
-S.x64-Dv8\u启用\u回溯=1-Dv8\u可以使用\u vfp2\u指令=true-Darm\u fpu=v
Installing libv8 (3.16.14.3) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb 
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
                 ^
1 error generated.
make[1]: *** [/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o] Error 1
make: *** [x64.release] Error 2
/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
    build/gyp/gyp --generator-output="out" build/all.gyp \
                  -Ibuild/standalone.gypi --depth=. \
                  -Dv8_target_arch=x64 \
                  -S.x64  -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3
  CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o


Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/gem_make.out

An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
$ export CXX=/usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8 
$ export CPP=/usr/local/Cellar/gcc48/4.8.2/bin/cpp-4.8 
$ export CC=/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8 
$ which $CXX
/usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
$ which $CPP
/usr/local/Cellar/gcc48/4.8.2/bin/cpp-4.8
$ which $CC
/usr/local/Cellar/gcc48/4.8.2/bin/gcc-4.8
$ bundle install
…
Installing libv8 (3.16.14.3) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/chris/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb 
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Using compiler: /usr/local/Cellar/gcc48/4.8.2/bin/g++-4.8
g++-4.8: error: unrecognized command line option '-Wnewline-eof'
make[1]: *** [/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [x64.release] Error 2
/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
    build/gyp/gyp --generator-output="out" build/all.gyp \
                  -Ibuild/standalone.gypi --depth=. \
                  -Dv8_target_arch=x64 \
                  -S.x64  -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3
  CXX(target) /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o


Gem files will remain installed in /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/chris/.rvm/gems/ruby-1.9.3-p448@website/gems/libv8-3.16.14.3/ext/libv8/gem_make.out

An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.
$ brew install v8
==> Downloading https://github.com/v8/v8/archive/3.21.17.tar.gz
Already downloaded: /Library/Caches/Homebrew/v8-3.21.17.tar.gz
==> Checking out http://gyp.googlecode.com/svn/trunk
==> make native -j4 library=shared snapshot=on console=readline i18nsupport=off
OK, so this is now sorted. 

For future people with the same problem, I was suffering from having ruby built against a previous installation of OS X.

Fixed by completely nuking rvm and starting from scratch, though I imagine you could just uninstall/reinstall the offending ruby.

More details on how the problem was solved here:

https://github.com/cowboyd/libv8/issues/120

I had this same problem when I upgraded from OSX Mountain Lion to OSX Mavericks. The patch level of ruby 1.8.7 apparently matters.

Upgrading from ruby-1.8.7-p354 to ruby-1.8.7-375 did the trick for me.

libv8 (3.16.14.3-x86_64-darwin-13) and the therubyracer (0.12.0) gems installed without problem.

assuming you use rbenv:

rbenv versions
  system
  * 1.8.7-p354
  2.0.0-rc2

rbenv uninstall 1.8.7-p354
rbenv install 1.8.7-p375

rbenv versions
  system
  * 1.8.7-p375
  2.0.0-rc2

bundle install
sudo apt-get install nodejs
bundle update therubyracer