Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

libv8 on Windows #29

Closed
yagmurdursun opened this Issue February 10, 2012 · 51 comments
yagmurdursun

I work on Windows and I developed an application. It was working but after installed a gem (twitter-bootstrap-rails) I started to get "Python not found." What can I do about it?

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

c:/Ruby192/bin/ruby.exe extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.
Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=c:/Ruby192/bin/ruby
Checking for Python...Unable to build libv8: Python not found!

Charles Lowell
Owner
yagmurdursun

so should I change my platform?

suffering

Not supporting windows make me so sad~~, I can't change my plateform. I've installed ubuntu linux as the second system, but I can only connect to network by a software that only supports windows.

Charles Lowell
Owner
yagmurdursun

finally I went to work on ubuntu :/

Roma Milushov

=(

I'm working in Windows on VirtualBox with Debian. One monitor for Debian and one for Windows... Internet works like just plug an another computer on lan, you can even copy/paste between systems and it works pretty fine for me for that kind of problems. :)

Diego Mesa

On windows 7, with ruby193 I installed python27, I added to the PATH variable the python's folder, I wrote gem install libv8 in the console and libv8 was succesfully installed

Terfender

diegomesata, can you elaborate more on this? which path variable? and where is it?
I am using rubygems1.8.17 and python 2.7

Diego Mesa

You can find the PATH variable in Windows in Control Panel -> System -> Advanced System Configuration -> Environment Variables.

My PATH variable is: C:\Ruby192\bin;C:\Python27

In a Command Prompt with Ruby, you can set the variable for that console using the command

SET PATH=C:\Ruby192\bin;C:\Python27

You can check the values using the command

PATH

Hope this helps

Diego Mesa

Ohh dont forget to install the Ruby Dev Kit https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

Terfender

diegomesata, thanks a lot. it works

Charles Lowell
Owner

@diegomesata Does that mean you able to get therubyracer to install?

Diego Mesa

hello cowboyd, no, I can't install therubyracer (yet). I'm working on windows 7 64 bits, the error I got trying to install the gem is: g++.exe: c:/Ruby192/lib/ruby/gems/1.9.1/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a: No such file or directory

Looks like some process building libv8 by hand in a static way for windows could fix the issue, like suggest http://code.google.com/p/pyv8/wiki/HowToBuild that was getting a similar error on osx.

My current project doesn't need therubyracer, so, in the Gemfile I commented the #gem 'therubyracer'

Antti Hukkanen

I'm having the same problem as @diegomesata. I actually could install the libv8 gem after installing python 2.7.x but the therubyracer gem still won't install because there is no compiled binary for libv8.a, so the install process gives me the same error as specified above.

If someone builds/compiles this file for windows 7 64 bit environment, let me know because I think it will solve the problem!

Yossale

@cowboyd I'll be glad to help with compiling it if you could point out what I should be doing - I have win7 764bit
you can email me at yossale [at] gmail

cielo
cielo commented May 10, 2012

Same problem here.

Win7, 64bit
Ruby 1.9.3p125

gem install libv8

If I try installing libv8 in command line with above input, I get a window error dialogue with title 'patch.exe' and a text saying that 'patch.exe has stopped working'. The console does not display any other information, and it claims it has successfully installed libv8, which it actually isn't.

After on, if I do bundle install, 'therubyracer (0.10.1)' will still fail to install with a error message 'libv8.a' missing.

I need 'therubyracergem' to use 'twitter-bootstrap-rails' gem.

Charles Lowell
Owner
cowboyd commented May 10, 2012

For those interested, I'm converting libv8 to use the GYP build instead of scons. @cielo @yossale Can you build from master?

cielo
cielo commented May 10, 2012

Hi, if I build from master, it fails with below error message.

Using libv8 (3.10.8.0) from https://github.com/cowboyd/libv8 (at master) with na
tive extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

        C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
extconf.rb:8:in ``': No such file or directory - make ia32.release (Errno::ENOEN
T)
        from extconf.rb:8:in `block in <main>'
        from extconf.rb:7:in `chdir'
        from extconf.rb:7:in `<main>'


Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/bundler/gems/l
ibv8-b981c474f1d4 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/bundler/gems/libv8-b981c474f1d4
/ext/libv8/gem_make.out
An error occurred while installing libv8 (3.10.8.0), and Bundler cannot continue
.
Make sure that `gem install libv8 -v '3.10.8.0'` succeeds before bundling.
Charles Lowell
Owner
cowboyd commented May 10, 2012

let's try compiling manually first:

rake clean
rake checkout
rake manual_compile
cielo
cielo commented May 10, 2012

I am new to rake and gem so I have not done any manual compiling before. I am not sure if I am doing things right.

I first cloned libv8 repo to my system and had to do bundle install to install any missing gem. (rspec was missing.)

And then I ran rake clean which ran successful.

But it seems that the command fails from rake checkout with following output.

C:\Users\anderson\ruby\libv8>rake clean
rm -rf pkg
git clean -df
cd C:/Users/anderson/ruby/libv8/vendor/v8 && git clean -dxf

C:\Users\anderson\ruby\libv8>rake checkout --trace
** Invoke checkout (first_time)
** Execute checkout
git submodule update --init
Submodule 'vendor/v8' () registered for path 'vendor/v8'
git fetch
git checkout 3.10.8
HEAD is now at e675a0f... Version 3.10.8
make dependencies
rake aborted!
Command failed with status (127): [make dependencies...]
C:/Ruby193/lib/ruby/1.9.1/rake/file_utils.rb:53:in `block in create_shell_runner
'
C:/Ruby193/lib/ruby/1.9.1/rake/file_utils.rb:45:in `call'
C:/Ruby193/lib/ruby/1.9.1/rake/file_utils.rb:45:in `sh'
C:/Ruby193/lib/ruby/1.9.1/rake/file_utils_ext.rb:39:in `sh'
C:/Users/anderson/ruby/libv8/Rakefile:16:in `block (2 levels) in <top (required)
>'
C:/Users/anderson/ruby/libv8/Rakefile:13:in `chdir'
C:/Users/anderson/ruby/libv8/Rakefile:13:in `block in <top (required)>'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `call'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `execute'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain'
C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:144:in `invoke'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_lev
el'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `each'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handlin
g'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:88:in `top_level'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:66:in `block in run'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handlin
g'
C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run'
C:/Ruby193/bin/rake:32:in `<main>'
Tasks: TOP => checkout

C:\Users\anderson\ruby\libv8>
Charles Lowell
Owner
cowboyd commented May 10, 2012

I should mention that you will need make, subversion and python installed in order to build.

cielo
cielo commented May 10, 2012

I am sure that I have 'git', 'svn', 'python' command added to the path, but I do not think I have 'make'.

I uses ruby dev kit (http://rubyinstaller.org/add-ons/devkit/) which compiles some of the gems that requires C based compile.

Charles Lowell
Owner
cowboyd commented May 10, 2012

I don't have experience with it, but ruby extensions require make to compile, so it must be on the system somewhere. Perhaps devkit has it stashed away somewher off the main path?

Charles Lowell
Owner

@cielo I've again update to a 3.11 which should have several enhancements to the upstream build. Any chance you can get it to work?

cielo
cielo commented June 21, 2012

It still produces an error.

>>>gem install libv8
Fetching: libv8-3.11.8.0.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing libv8:
        ERROR: Failed to build gem native extension.

        C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.0/ext/libv8/compiler.rb:30:in `
`': No such file or directory - which g++ (Errno::ENOENT)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.0/ext/libv8/compil
er.rb:30:in `check_gcc_compiler'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.0/ext/libv8/compil
er.rb:7:in `compiler'
        from extconf.rb:12:in `block in <main>'
        from extconf.rb:11:in `chdir'
        from extconf.rb:11:in `<main>'


Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.1
1.8.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.0/ext/libv8/g
em_make.out
>>>
stereobooster

@cielo try to type in console

which g++

I'm getting following

which g++
D:\tools\rubydevkit\mingw\bin\g++.EXE
stereobooster

for libv8

gem install libv8
Building native extensions.  This could take a while...
Successfully installed libv8-3.11.8.0
1 gem installed
Installing ri documentation for libv8-3.11.8.0...
Installing RDoc documentation for libv8-3.11.8.0...

for therubyracer

My build fails because patch.exe fails. I change patch to this and get following error

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

        D:/tools/ruby192/bin/ruby.exe extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=D:/tools/ruby192/bin/ruby
extconf.rb:15:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)


Gem files will remain installed in D:/tools/ruby192/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.1 for inspection.
Results logged to D:/tools/ruby192/lib/ruby/gems/1.9.1/gems/therubyracer-0.10.1/ext/v8/gem_make.out

Here it is, but in libv8 it's now called libv8_include_path

Charles Lowell
Owner

yes, we need to patch older versions of the rubyracer because it is using the newer version of libv8, not the one that is in the bundle.

This is why in the latest version of the rubyracer, we explicitly activate a compatible version of libv8: https://github.com/cowboyd/therubyracer/blob/master/ext/v8/build.rb#L6

However, if you can get libv8 to build, then we're really close. Tell me, can you build therubyracer from master?

stereobooster
...
D:/tools/ruby192/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.0/lib/libv8.rb:30:in `block in libv8_objects': no libv8 object base (RuntimeError)
        from D:/tools/ruby192/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.0/lib/libv8.rb:29:in `map'
        from D:/tools/ruby192/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.0/lib/libv8.rb:29:in `libv8_objects'
        from D:/tools/ruby192/lib/ruby/gems/1.9.1/bundler/gems/therubyracer-4e6f848d4de4/ext/v8/build.rb:50:in build_with_rubygem_libv8'
        from extconf.rb:18:in `<main>'
Charles Lowell
Owner

this would indicate that libv8 did in fact, not build properly. Have you tried just manually building it yourself? This version of therubyracer does not actually require the libv8 gem. If you can get libv8 installed into your system somewhere so that -lv8 will properly link

stereobooster

I didn't see any error while installing gem because it's fails silently. Here is the fix
Actual error is

...
D:\tools\rubydevkit\bin\make.EXE: *** No rule to make target `ia32.release'.  Stop.
stereobooster

I'm actually not sure if it's possible to build libv8 on windows with Mingw, because V8 gyp-files on windows generating MSVC project. Or am I wrong?

All I could find about building V8 with MinGW, mention Scons. So those are old instructions. But SConstruct still there.

stereobooster

It appears that i didn't bundle exec rake checkout before:
now error looks

...
tools\rubydevkit\bin\make.EXE: *** [ia32.release] Error 127
GYP_GENERATORS=make \
        build/gyp/gyp --generator-output="out" build/all.gyp \
                      -Ibuild/standalone.gypi --depth=. \
                      -Dv8_target_arch=ia32 \
                      -S.ia32 -Dhost_arch=ia32

After editing Makefile (replace build/gyp/gyp with python build/gyp/gyp) Error looks like:

...
/bin/sh: /d/projects/libv81/vendor/v8/D:/toolsrubydevkitbinmake.EXE: No such file or directory
tools\rubydevkit\bin\make.EXE: *** [ia32.release] Error 127

After editing extconf.rb

puts `env CXX=#{compiler.sub('\\','/')} LINK=#{compiler.sub('\\','/')} make #{libv8_arch}.release GYPFLAGS="-Dhost_arch=#{libv8_arch}"`

Getting

make[1]: *** No rule to make target `../build\all.gyp', needed by `Makefile.ia32'.  Stop.

After editing vendor/v8/out/Makefile.ia32 - replace Makefile.ia32: $(srcdir)/build\all.gyp with Makefile.ia32: $(srcdir)/build/all.gyp etc. I get this

ruby ext/libv8/extconf.rb
creating Makefile
/d/projects/libv81/vendor/v8
make[1]: Entering directory `/d/projects/libv81/vendor/v8/out'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/d/projects/libv81/vendor/v8/out'
  Successfully built RubyGem
  Name: libv8
  Version: 3.11.8.0
  File: libv8-3.11.8.0-x86-mingw32.gem

So it's still unsuccessful. One more additional check

Charles Lowell
Owner

fyi, you don't need to use the libv8 gem to build therubyracer. You can also install from source as a shared library.

stereobooster

fyi, you don't need to use the libv8 gem to build therubyracer. You can also install from source as a shared library

I can't build v8 on windows with mingw. So this mean I can't build therubyracer anyway. Or am I wrong?
Building libv8 gem is the same as build v8 itself, because it's internally calls v8 builder (make ia32.release).

stereobooster

There is hardcode in GYP: for windows it supports only one toolchain msvs. Didn't test, but I believe that msvs binaries are incompatible with MinGW. But it is possible to use those binaries through ffi. There is no support cross OS compilation in GYP (but there is cross ARCHITECTURE compilation). Chromium team won't implement those features, but they are "happy to accept patches". I'm personalty don't want to dig in GYP source to get this work.
Another option: is to use build with scons. But scons build is deprecated by Chromium team.

I believe that easiest way here: try to do cross compilation with scons. There is old patch to enable cross OS compilation with scons.

Charles Lowell
Owner

Yikes! It does look like there is some fairly fresh work happening in this area to get it working, which you probably saw on google. Is this you or somebody else? http://code.google.com/p/v8/issues/detail?id=2197

stereobooster

It's somebody else. I get further then him. I was able to run v8 build against MinGW. But it doing nothing (make[1]: Nothing to be done for 'all'.).

stereobooster

I builded v8 on windows with following command scons os=win32 toolchain=gcc library=shared. As the result i get bunch of files in obj\release folder and v8.dll, v8.lib, v8.a, v8preparser.a, v8preparser.dll in the root.

But it seems didn't produce libpreparser_lib.a, libv8_base.a, libv8_nosnapshot.a, libv8_snapshot.a

Charles Lowell
Owner

Hmm... it looks like the scons build does not generate two separate static libraries for base and snapshot. But that's OK. I think you just need to link directly against v8.a and you should be fine.

stereobooster

I successfully build therubyracer on windows see cowboyd/therubyracer#172

stereobooster

Another option is to compile v8 with Visual Studio Express. And try to link against it. According to this post it's possible.

Hiran Peiris

Solution found! 100% working...

The reason for all of these problems is the therubyracer-0.11.0beta1-x86-mingw32.gem and the v8.dll.

I have complied the necessary dlls and gem files and upload them to github.

download the package and follow the instructions...

https://github.com/hiranpeiris/therubyracer_for_windows

good luck :-)

Petko Bordjukov
Collaborator

I was able to compile a static library on Windows with VS 2008 express without any patching whatsoever. Not sure if I can link therubyracer against it with mingw's linker though. @cowboyd do you think this is practical enough to be worth the time (as in do you think you can provide Windows binaries if we are able to automate the compilation process, having in mind the required stuff below)?

Prerequisites for compilation:

  • Python 2.* (to generate a VS project with gyp)
  • Subversion (to checkout a special version of cygwin)
  • VS 2008 Express free (to build the project)

Also it would be great if somebody with more than my 30 minutes of experience with C++ on Windows would lend a hand :smile:

Hiran Peiris
Charles Lowell
Owner

@hiranpeiris I think we can all agree that the simplest installation is the way to go. The simplest way to get there is to have a fully automated build from source that can then be leveraged to construct binary releases. That's not to detract from the work you have done at all. I think it's awesome, and I will be sure to point Windows users to your project.

@ignisf If you can automate the build, then I'd be happy to provide windows binaries. A Vagrantfile or image with the appropriate toolchain would be boss.

stereobooster

The question if the ibv8 builded with VS 2008 will be compatible with Ruby builded with MinGW. I believe not. I saw post about converting VS binaries to MinGW (or make them compatible). @luislavena can you consult us about this question?

@hiranpeiris,@ignisf see options and those PRs cowboyd/libv8#40, cowboyd/libv8#41

Luis Lavena

libv8 builded with VS 2008 will be compatible with Ruby builded with MinGW

If libv8 is build as static object, it might be possible to link, but also will use other CRT function references that is not available by basic MSVCRT.

If libv8 is build as shared resource: it will link to a different version of the CRT and that is a recipe for crash.

The simplest way to get there is to have a fully automated build from source that can then be leveraged to construct binary releases.

I don't think scons support cross-compilation that can be used to produce libv8 in linux that targets Windows.

The best approach is introduce changes to this project that allow native compilation of libv8 static library and release those as x86-mingw32 gems, which later can be used to link therubyracer.

juanmendez juanmendez referenced this issue in thethemefoundry/forge March 14, 2013
Closed

Error: Failed to build gem native extension #61

Andrew Pennebaker

Please provide a Windows version. Unix is great, but many of us need Windows support.

Graham Siener gsiener referenced this issue in pivotal/projectmonitor April 25, 2013
Closed

Unable to bundle install Project Monitor on Windows #18

Petko Bordjukov ignisf closed this December 04, 2013
Petko Bordjukov
Collaborator

See #111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.