Unable to install libv8 gem on Cygwin

How to install libv8 gem? I can not install libv8 gem. When I try, I get the following error.

$ gem install libv8
Building native extensions.  This could take a while...
ERROR:  Error installing libv8:
        ERROR: Failed to build gem native extension.

        /usr/bin/ruby.exe extconf.rb
creating Makefile
Using compiler: /usr/bin/g++
which: no gmake in (/usr/local/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/system32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn/VSShell/Common7/IDE:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/c/Program Files/Heroku/bin:/cygdrive/c/Program Files/ruby-1.9.2/bin:/cygdrive/c/Program Files/git/bin:/cygdrive/c/Program Files/git/cmd:/cygdrive/c/Program Files/DTN/IQFeed:/cygdrive/c/Program Files/OpenVPN/bin:/cygdrive/c/Program Files/Java/apache-ant-1.8.3/bin:/usr/lib/lapack:/cygdrive/c/Program Files/Notepad++:.:/cygdrive/c/Program Files/Java/android-sdk/platform-tools/:/cygdrive/c/Program Files/Java/android-sdk/tools/:/cygdrive/c/Program Files/Java/jdk1.7.0_03/bin)
In file included from ../src/conversions-inl.h:42:0,
                 from ../src/conversions.cc:32:
../src/platform.h:77:12: error: new declaration โ€˜int random()โ€™
/usr/include/cygwin/stdlib.h:29:6: error: ambiguates old declaration โ€˜long int random()โ€™
make[1]: *** [/usr/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.13/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/conversions.o] Error 1

I tried to use

$ gem install libv8 --pre
Fetching: libv8-3.5.10.beta1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed libv8-3.5.10.beta1
1 gem installed

But bundle installit still wonโ€™t work. He was still trying to install version 3.11.8.13.

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

libv8 gem is not in my gemfile. I donโ€™t know how to find out that I am trying to use it, but during the search I saw that rubyracer is using libv8, and I have

group :assets do
  gem 'therubyracer', :platform => :ruby

I even tried to edit the file /usr/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.13/src/platform.hand comment out line 77:

//int random();

But when I started gem install libv8, it overwritten my changes and still threw an error. I saw the trick in gem install libv8 --help, so I edited the file again and commented out line 77, and tried

cd /usr/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.13/vendor/v8
make

However, this has just led to various errors:

In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/winsock2.h:56:0,
                 from ../src/win32-headers.h:77,
                 from ../src/platform-win32.cc:31:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/psdk_inc/_fd_types.h:100:2: warning: #warning "fd_set and associated macros have been defined in sys/types.      This can cause runtime problems with W32 sockets"
In file included from ../src/win32-headers.h:80:0,
                 from ../src/platform-win32.cc:31:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/wspiapi.h:26:41: error: expected โ€˜>โ€™ before numeric constant
../src/platform-win32.cc: In function โ€˜int random()โ€™:
../src/platform-win32.cc:122:12: error: new declaration โ€˜int random()โ€™
/usr/include/cygwin/stdlib.h:29:6: error: ambiguates old declaration โ€˜long int random()โ€™
+5
3

Cygwin, , Windows. therubyracer libv8 Windows, : therubyracer . Windows, , Rails.

libv8, nodejs . , .

+1

, , , , .

, "therubyracer" - - javascript.

, Gemfile 'therubyracer' 'therubyrhino'. ( , : https://github.com/sstephenson/execjs#readme

+4

I just hit the same issue on my Win7 dev machine. It looks like setting https://github.com/hiranpeiris/therubyracer_for_windows and adding gem 'therubyracer'to Gemfilesorts things.

Before:

$ rails generate
c:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
(...)

This basically means that Rails needs rubyracerand therefore libv8.

After:

$ rails generate
    SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
    This poses a security threat. It is strongly recommended that you
    provide a secret to prevent exploits that may be possible from crafted
    cookies. This will not be supported in future versions of Rack, and
    future versions will even invalidate your existing user cookies.

    Called from: c:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.

Usage: rails generate GENERATOR [args] [options]
(...)
+1
source