Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Unable to compile therubyracer on Mountain Lion #181

Closed
ldallas opened this issue Jul 26, 2012 · 12 comments
Closed

Unable to compile therubyracer on Mountain Lion #181

ldallas opened this issue Jul 26, 2012 · 12 comments

Comments

@ldallas
Copy link

ldallas commented Jul 26, 2012

When I run bundle install this is what error I get:

Installing therubyracer (0.10.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/Lily/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb 

checking for main() in -lobjc... yes
creating Makefile

make
compiling rr.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
rr.cpp: In function ‘VALUE rr_define_finalizer(VALUE, void_, VALUE)’:
rr.cpp:48: warning: no return statement in function returning non-void
rr.cpp: In function ‘v8::Handlev8::Value rr_rb2v8(VALUE)’:
rr.cpp:151: warning: implicit conversion shortens 64-bit value into a 32-bit value
rr.cpp: In function ‘VALUE rr_define_finalizer(VALUE, void_, VALUE)’:
rr.cpp:48: warning: control reaches end of non-void function
compiling v8.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_array.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_callbacks.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_context.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_date.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_debug.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_exception.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
v8_exception.cpp:10: warning: ‘::stack’ defined but not used
compiling v8_external.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
v8_external.cpp:10: warning: ‘::references’ defined but not used
compiling v8_function.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_handle.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_locker.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
v8_locker.cpp: In function ‘VALUE::Lock::Delete(VALUE)’:
v8_locker.cpp:45: warning: no return statement in function returning non-void
v8_locker.cpp: In function ‘VALUE::Unlock::Delete(VALUE)’:
v8_locker.cpp:85: warning: no return statement in function returning non-void
v8_locker.cpp:85: warning: control reaches end of non-void function
v8_locker.cpp: In function ‘VALUE::Lock::Delete(VALUE)’:
v8_locker.cpp:45: warning: control reaches end of non-void function
compiling v8_message.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_object.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_script.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_string.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
v8_string.cpp: In function ‘VALUE::New(VALUE, VALUE)’:
v8_string.cpp:18: warning: implicit conversion shortens 64-bit value into a 32-bit value
v8_string.cpp: In function ‘VALUE::NewSymbol(VALUE, VALUE)’:
v8_string.cpp:23: warning: implicit conversion shortens 64-bit value into a 32-bit value
compiling v8_template.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_try_catch.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_v8.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
v8_v8.cpp: In function ‘VALUE::SetFlagsFromString(VALUE, VALUE)’:
v8_v8.cpp:22: warning: implicit conversion shortens 64-bit value into a 32-bit value
compiling v8_value.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
compiling v8_weakref.cpp
cc1plus: warning: command line option "-Wdeclaration-after-statement" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-Wimplicit-function-declaration" is valid for C/ObjC but not for C++
linking shared-object v8.bundle
i686-apple-darwin11-llvm-g++-4.2: /Users/Lily/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a: No such file or directory
make: *** [v8.bundle] Error 1

Gem files will remain installed in /Users/Lily/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.1 for inspection.
Results logged to /Users/Lily/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.1/ext/v8/gem_make.out
An error occured while installing therubyracer (0.10.1), and Bundler cannot continue.
Make sure that gem install therubyracer -v '0.10.1' succeeds before bundling.

@cowboyd
Copy link
Collaborator

cowboyd commented Jul 26, 2012

The problem is that the version of v8 used by current release of therubyracer will not compile on Mountain Lion. Are you able to use the pre-release?

@gdavis
Copy link

gdavis commented Jul 26, 2012

I'm having the same issue and made a stackoverflow post about it here:
http://stackoverflow.com/questions/11677480/after-xcode-4-4-and-osx-10-8-installation-failed-to-build-gem-native-extensio

@gdavis
Copy link

gdavis commented Jul 26, 2012

@cowboyd libv8 does install successfully using 3.11.8.3

@ldallas
Copy link
Author

ldallas commented Jul 26, 2012

@cowboyd thanks, resolved using 3.11.8.3 as well.

@sharipov-ru
Copy link

gem 'therubyracer', '0.11.0beta5'
gem 'libv8', '~> 3.11.8'

works fine for me

@ldallas
Copy link
Author

ldallas commented Jul 27, 2012

I'm installed with those versions of therubyracer and libv8 however now I'm getting another issue that seems connected to this with twitter-bootstrap-rails. I posted an issue here: seyhunak/twitter-bootstrap-rails#321

@shwoodard
Copy link

I was able to get this working using 0.11.0beta5 and ~> 3.11.8 on os x 10.8, but then when I try to deploy to my ubuntu pre-production environment rake assets:precompile, it goes fubar trying to use one of the shared libraries.

@ryenski
Copy link

ryenski commented Jul 30, 2012

I have the same problem as shwoodard.

Starting the app fails with the following message:

ruby: symbol lookup error: /srv/app/shared/bundle/ruby/1.8/gems/therubyracer-0.11.0beta5-x86_64-linux/lib/v8/init.so: undefined symbol: rb_intern2

@cowboyd
Copy link
Collaborator

cowboyd commented Aug 1, 2012

@mysmallidea It looks like you are running ruby 1.8 and the binary gem was compiled with ruby 1.9. Right now therubyracer does not ship fat gems, so you will have to use the source. Rumour has it that @luislavena has a solution in the works for compiling a single binary gem for multiple versions of the binary interface.

Until then, I would recommend installing the source version of the gem.

@minaguib
Copy link

minaguib commented Aug 4, 2012

I've run into a similar-but-different issue.

Taking bundler out of the equation. Installed the libv8 gem (v 3.11.8.3) successfully. Next trying to install therubyracer gives:

# gem install therubyracer  --pre
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
  ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
creating Makefile

make
c++ -I. -I/opt/local/lib/ruby/gems/1.8/gems/libv8-3.11.8.3/vendor/v8/include -I. -I/opt/local/lib/ruby/1.8/i686-darwin12 -I. -I/opt/local/include -std=c89 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE  -I/opt/local/include -std=c89 -Wall -g -rdynamic -fno-common -Os -arch x86_64  -fno-common -pipe -fno-common  -arch x86_64  -c accessor.cc
clang: warning: argument unused during compilation: '-rdynamic'
error: invalid argument '-std=c89' not allowed with 'C++/ObjC++'
make: *** [accessor.o] Error 1


Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/therubyracer-0.11.0beta6 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/therubyracer-0.11.0beta6/ext/v8/gem_make.out

Seems a bit weird to be a compiler error instead of a warning. Compiler info:

# c++ --version
Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.0.0
Thread model: posix

So it seems that c++ points to llvm-clang on my installion, and it seems that clang is more pedantic and produces a fatal error on an option (c89 standard) that doesn't make sense for the language (C++)

Hacking away a bit, I was able to simply edit the Makefile in ext/v8/ and delete "-std=c89". Compilation worked well afterwards. I couldn't find references to "-std=c89" anywhere in therubyracer's sources, so I'm not sure how CPPFLAGS is assembled in that Makefile.

Another easier solution was to explicitly use a different compiler:

# CXX=g++ gem install therubyracer  --pre
Building native extensions.  This could take a while...
Successfully installed therubyracer-0.11.0beta6
1 gem installed
Installing ri documentation for therubyracer-0.11.0beta6...
Installing RDoc documentation for therubyracer-0.11.0beta6...

Compiler info:

# g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

g++ (llvm-gcc) still doesn't like -std=c89, but it just produces a warning instead of an error, and the compilation/installation proceeds smoothly as seen above.

The same trick applies when using bundler (in my case 'bundle' afterwards simply found the gem I had installed above, but I'd imagine without that step a simple CXX=g++ bundle ... would work as well).

These are, of course, hacks. I'm not sure how therubyracer can fix it in a permanent fashion (removing -std=c89 flag, or demanding compilation via llvm-gcc).

@cowboyd
Copy link
Collaborator

cowboyd commented Aug 8, 2012

@minaguib As you surmised the -c89 flag is added by ruby, not by therubyracer, so there's not much to do about it except make sure you're using g++

But these are all issue that really have to do with any c++ extension and not therubyracer in particular, since it does not ask for a specific c++ compiler only a c++ compiler.

@cowboyd cowboyd closed this as completed Aug 9, 2012
@johana-star
Copy link

@minaguib Thanks! this fixed it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants