My favorites | Sign in
Project Hosting will be READ-ONLY Thursday at 3:00pm UTC for up to 3 hours for network maintenance.
v8
Project Home Downloads Wiki Issues Source
Search
for
BuildingOnWindows  
Detailed instructions for building V8 on Windows.
Updated Aug 8, 2011 by yangguo@chromium.org

Building on Windows

After having installed all the prerequisites you need to add both Python and SCons to you PATH. The following example assumes that Python version 2.5.2 and SCons version 1.0.0 have been installed in their default locations.

> set PATH=C:\Python25;C:\Python25\Scripts;%PATH%`
> scons

See below for additional information on building on different versions of Visual Studio.

There are Visual Studio project files located in tools\visual studio for building V8 using the Visual Studio IDE. Please refer to the README.txt file in that directory for details. When using the Visual Studio IDE for building the project please update the PATH in My Computer->Properties->Advanced->Environment Variables as the Visual Studio project files uses Python for some of the build steps.

Using Visual Studio 2005

SCons 1.0.0 should be able to detect Visual Studio 2005 and set up the build environment automatically so no additional options should be required to run the commands mentioned in the documentation.

To build using Visual Studio 2005 however requires Visual Studio 2005 SP1 to be installed. Please download and install VS80sp1-KB926601-X86-ENU.exe from Microsoft. Link errors like the one below is an indication of Visual Studio 2005 SP1 not beeing installed.

LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in mksnapshot.obj
LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: virtual char const * __thiscall std::exception::what(void)const " (?what@exception@std@@UBEPBDXZ) already defined in mksnapshot.obj

Selecting Visual Studio C++ Runtime Library

The SCons build has an option to control which Visual Studio C++ Runtime Library to use when linking V8. The possible options are static (statically linked in to the V8 library) and dynamic (using the DLL version). The default is static. The following example uses the shared runtime library.

> scons msvcrt=shared

NOTE: The runtime library to use (static or shared) can be selected independently of the type selected for the V8 library itself (also static or shared).

Controlling Link-time Code generation

The SCons build option msvcltcg can be used to control whether Visual C++ is instructed to do link-time code generation or not. The default is on the it can be switched off using off.

> scons msvcltcg=off

Using Visual Studio 2008

As SCons version 1.0.0 does not detect Visual Studio 2008, you will need to supply an additional env option to SCons. The env option is used to override the environment paths SCons is using. For Visual Studio 2008 it is required to override PATH, INCLUDE and LIB.

The setup batch file supplied with Visual Studio 2008 will set the environment variables PATH, INCLUDE and LIB to the correct values. To use the Visual Studio 2008 environment setup either use the link Visual Studio 2008 Command Prompt from the Visual Studio 2008 installation, or use a fresh Command Prompt and run the vcvarsall.bat from the VC directory of the Visual Studio 2008 installation. Assuming that the default installation directories have been used the following command will do that.

> "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"

Now V8 can be built by passing the environment variables to SCons.

> scons env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%"

If for some reason setting the environment variables is not feasible the paths can be passed directly. The following example passes these paths for a Visual Studio 2008 installation assuming that the default installation directories have been used.

> scons env="PATH:C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools,INCLUDE:C:\Program Files\Microsoft Visual Studio 9.0\VC\include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include,LIB:C:\Program Files\Microsoft Visual Studio 9.0\VC\lib;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib"

Using Visual C++ Express 2008

As for Visual Studio 2008 SCons alos does not detect Visual C++ Express 2008 and the env 2options to SCons is required. In contrast to Visual Studio 2008 the path for Visual C++ Express 2008 are determined correctly so only include and library paths have to be overridden. The following example passes the include and library path for a Visual C++ Express 2008 installation assuming that the default installation directories have been used.

>scons env="INCLUDE:C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include;C:\Program Files\Microsoft Visual Studio 9.0\VC\include,LIB:C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib;C:\Program Files\Microsoft Visual Studio 9.0\VC\lib"

Running tests on Windows

When running the tests using tools\test.py on Windows SCons is used to build the tests written in C++. Therefore if using Visual Studio 2008 or Visual C++ Express 2008 the additional ´env´ option have to be passed. The script tools\test.py has an option -S to specify options which are passed to SCons. For Visual C++ Express 2008 it will look like this.

>tools\test.py -S env="INCLUDE:C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include;C:\Program Files\Microsoft Visual Studio 9.0\VC\include,LIB:C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib;C:\Program Files\Microsoft Visual Studio 9.0\VC\lib"

When running tests turning off link-time code generation will reduce link time significally. This is useful when running the tests repeatedly.

>tools\test.py -S msvcltcg=off

Building 64-bit V8 on 64-bit Windows 7

A 64-bit build of V8 can be built on Windows 7 using Visual Studio 2008 and MS Windows SDK v7.0 or v7.1. 64-bit V8 on Windows is not currently used in any applications we know of, but it builds and passes all tests. Here the commands that work for us:

Open a "Visual Studio 2008 x64 Win64 Command Prompt"

> scons env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%" -j4 arch=x64 mode=debug

You may also add "d8", "sample=shell", or "cctests" to build particular targets.

To run tests,

python tools/test.py -j4 --no-build --mode=debug

You may also add "mozilla" or "sputnik" to the end of the command line.

Paths on 64-bit Windows Vista

SCons 1.0.0 does not support neither Visual Studio 2005 nor Visual Studio 2008 on 64-bit Windows Vista, so the environment override is required for both versions. Using the setup batch file supplied with Visual Studio and invoking SCons as follows is the simplest solution.

> scons env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%"

Explicit Visual Studio 2008 paths

For Visual Studio 2008 the installation on 64-bit Windows Vista has files in both C:\Program Files and C:\Program Files (x86). If not using the setup batch file supplied with Visual Studio 2008 the following environment override should used when invoking SCons.

PATH:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools,INCLUDE:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include,LIB:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Lib;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib

Building the hello_world sample on Windows

To build the hello_world.cpp sample from the Getting Started section of the documentation on Windows you can use the Microsoft C++ compiler cl directly. First open either the Visual Studio 2005 Command Prompt or the Visual Studio 2008 Command Prompt depending on your version if Visual Studio. Change to the directory where V8 is checked out (and v8.lib is located). Place the file hello_world.cpp there and run:

cl /Iinclude hello_world.cpp v8.lib

This will produce hello_world.exe ready to run.

If using a shared library use the following command to compile hello_world.cpp:

cl /Iinclude /DUSING_V8_SHARED hello_world.cpp v8.lib

This will produce hello_world.exe requiring v8.dll in the current directory or on the PATH to run.

Comment by autoly...@gmail.com, Sep 8, 2008

Using Visual C++ 2008 with Windows SDK for Windows Server 2008 and .NET Framework 3.5

You need to pass in the environment variables to scons as follows

scons env="PATH:C:\Program Files\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools,INCLUDE:C:\Program Files\Microsoft Visual Studio 9.0\VC\include;C:\Program Files\Microsoft SDKs\Windows\v6.1\Include,LIB:C:\Program Files\Microsoft Visual Studio 9.0\VC\lib;C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib

Comment by loriaCar...@gmail.com, Oct 28, 2008

Yes autolysis line works fine but just be sure your SDK is being correctly pointed at (in my case was "...\Microsoft SDKs\Windows\v6.0a\Include"). Otherwise you might get src\platform-win32.cc(52) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

Comment by Arid...@gmail.com, Nov 20, 2008

Just a comment there is a spelling mistake.

After having installed all the prerequisites you need to add both Python and SCons to you PATH.

Should be your PATH.

Comment by sph...@gmail.com, Jan 3, 2009

For those using a 64bit Os, VC is split into both "Program Files", and "Program Files (x86)". Here is a modified scons command that works with this setup:

scons env="PATH:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools,INCLUDE:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include,LIB;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Lib;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib"

Comment by klapaut...@gmail.com, Jan 4, 2009

Using Shared v8 in Visual Studio 2003 (VC7.1) with delayed loading

The problem for vc71 is in the default arguments to some function declarations. These are simple to remove, but you'll obviously need to supply them explicitly.

Now, I wanted to be able to NOT use scripting in my app. Linking explicitly fails with a bunch of errors. Enter delayed loading:

  • compile with preproc macro USING_V8_SHARED defined
  • link with the import library
  • enter v8.dll under Linker Input page, in section "delay loaded DLLs" (bottom)
  • Wrap the v8-VS2003 header as shown below

The only problem with delayed loading is that we get LNK1194 due to data import from the library (in release mode) This is due to optimization, so we can turn it off temporarily. For me, the following was enough:

// avoid a warning
#pragma warning( disable : 4251 )

// Allows delay-loading v8.dll
#pragma optimize("g", off)
#include "v8-VS2003.h"
#pragma optimize("", on)

You can now either just use the v8 lib functions (the module is loaded automatically on first call), or check that it exists by calling LoadLibrary?("v8.dll") and testing the returned handle before use.

Comment by marioj...@gmail.com, Feb 15, 2009

Why do I get the following error while compiling the helloworld sample or the entire V8 source to a shared library?

platform-win32.obj : error LNK2001: unresolved external symbol imptimeGetTime@0 v8.dll : fatal error LNK1120: 1 unresolved externals

I'm using: - Windows Vista x86 - Visual Studio 2008 - Python 2.6.1 - SCons v1.2.0.r3842

If I try to compile the VS project, the same thing is happening: Static Library --> No Problems Shared Library --> Same Error

Thanks for help and sorry for my bad English.

Comment by paulbern...@gmail.com, Feb 19, 2009

I had exactly the same problem.

I added Winmm.lib to the linker and it works.

(Hope it helps)

Comment by marioj...@gmail.com, Feb 22, 2009

Hi paulbernuau! Thank you very much for your answer! Now I can build a shared library if I simply add the Winmm.lib to the VS project! But I don't know how to add the library when using SConstructor to build the V8 engine!? Would be nice if somebody could tell me how to do that. But that isn't very important. I think I can go on using VS. Thanks!

Comment by webphoenix.org@gmail.com, Feb 27, 2009

When I use the v8 in VC8 MFC Apps,It's show some errors like this: v8.h(424) : error C2059: syntax error : "string" v8.h(424) : error C2091: function return function and so on Who can tell me why and how to solve it? Thanks for help!

Comment by Sean.Kan...@gmail.com, Mar 26, 2009

I've got some linking errors with VS2005+windows sdk 6.1 and solved by adding 2 libs "C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib\Winmm.lib" "C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib\WSock32.lib"

Comment by grusi...@gmail.com, Apr 27, 2009

Linking winmm.lib and WSock32.lib should be added to the actual instruction.

Comment by plmdvy@gmail.com, May 4, 2009

is it possible to build v8 on mingw on windows?

Comment by benjamin...@gmail.com, Jun 16, 2009

I whant to build V8 under gcc-cygwin enviroment, is it possible ?

Comment by dush...@gmail.com, Aug 8, 2009

nice

Comment by datta.sa...@gmail.com, Sep 8, 2009

The build fails on my machine even though I have VS2005 installed on it. To fix it I had to use the following command line...

>vsvars32.bat 
>scons msvcrt=shared env="INCLUDE:%INCLUDE%,LIB:%LIB%"
Comment by n.vaug...@gmail.com, Oct 23, 2009

Hi,

When I build with

"scons mode=debug snapshot=on msvcrt=shared"

It fails with:

C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\typeinfo(139) : error C2220: warning treated as error - no 'obje ct' file generated C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\typeinfo(139) : warning C4275: non dll-interface class 'stdext:: exception' used as base for dll-interface class 'std::bad_cast'

C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\exception(241) : see declaration of 'stdext::exception' C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\typeinfo(138) : see declaration of 'std::bad_cast'
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\typeinfo(160) : warning C4275: non dll-interface class 'stdext:: exception' used as base for dll-interface class 'std::bad_typeid'
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\exception(241) : see declaration of 'stdext::exception' C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\typeinfo(159) : see declaration of 'std::bad_typeid'
scons: [obj\debug\mksnapshot.obj] Error 2 scons: building terminated because of errors.

D:\Development\thirdparty\v8>

Any ideas?

Comment by kurt.griffiths@gmail.com, Nov 12, 2009

To get the hello world sample to build, I also had to add ws2_32.lib. So here's my complete command line:

cl /Iinclude v8.lib Winmm.lib WSock32.lib hello_world.cpp ws2_32.lib

Comment by iamyuguo, Nov 27, 2009

When I use MinGW with toolchain=gcc set, it generates commands like this:

cl /Foobj\release\dtoa-config.obj /c src\dtoa-config.c -Werror -Wno-uninitialize d -m32 -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -DWIN32 /DV8 TARGET_ARCH_IA32 /DENABLE_DEBUGGER_SUPPORT /DV8_NATIVE_REGEXP /DENABLE_LOGGING AND_PROFILING /Isrc

Why? And how am I to compile it using MinGW?

Comment by bolter.fire, Dec 18, 2009

Anyone to put statically linked version somewhere? I cant build it too.

Comment by toyotabe...@gmail.com, Dec 18, 2009

Has anyone tried to used the Intel 11.x compiler?

Comment by lme...@gmail.com, Mar 16, 2010

Is there a MinGW (http://www.mingw.org) port?

Comment by lme...@gmail.com, Mar 16, 2010

I guess this is supposed to be the code for porting to mingw: http://codereview.chromium.org/18309 Anyone had any luck building? Is there a good site to document how to build using mingw instead of Visual Studio C++?

Comment by marco.ma...@gmail.com, Mar 20, 2010

As n.vaughan said, if I build with

scons env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%" msvcrt=shared mode=debug library=shared snapshot=on

it gives an error compiling mksnapshot.cc.

With

scons env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%" msvcrt=shared mode=debug library=shared snapshot=off

it's ok.

Comment by gdotthe...@gmail.com, Apr 10, 2010

Is there any way to build V8 with a Borland compiler? Has anyone made a C++ builder project file?

Comment by himat...@gmail.com, Apr 13, 2010

I must have done something wrong. v8.lib that I got is like 118 MB, and when I used it, it gave me these errors.

1>main.obj : error LNK2001: unresolved external symbol "public: void thiscall v8::Context::Exit(void)" (?Exit@Context@v8@@QAEXXZ) 1>main.obj : error LNK2001: unresolved external symbol "public: void thiscall v8::Context::Enter(void)" (?Enter@Context@v8@@QAEXXZ) 1>main.obj : error LNK2001: unresolved external symbol "public: static class v8::Persistent<class v8::Context> cdecl v8::Context::New(class v8::ExtensionConfiguration? ,class v8::Handle<class v8::ObjectTemplate?>,class v8::Handle<class v8::Value>)" (?New@Context@v8@@SA?AV?$Persistent@VContext@v8@@@2@PAVExtensionConfiguration@2@V?$Handle@VObjectTemplate@v8@@@2@V?$Handle@VValue@v8@@@2@@Z) 1>main.obj : error LNK2001: unresolved external symbol "public: class v8::Local<class v8::Value> thiscall v8::Script::Run(void)" (?Run@Script@v8@@QAE?AV?$Local@VValue@v8@@@2@XZ) 1>main.obj : error LNK2001: unresolved external symbol "public: static class v8::Local<class v8::Script> cdecl v8::Script::Compile(class v8::Handle<class v8::String>,class v8::ScriptOrigin? ,class v8::ScriptData? ,class v8::Handle<class v8::String>)" (?Compile@Script@v8@@SA?AV?$Local@VScript@v8@@@2@V?$Handle@VString@v8@@@2@PAVScriptOrigin@2@PAVScriptData@2@0@Z) 1>main.obj : error LNK2001: unresolved external symbol "private: static void cdecl v8::V8::DisposeGlobal?(class v8::internal::Object )" (?DisposeGlobal?@V8@v8@@CAXPAPAVObject@internal@2@@Z) 1>main.obj : error LNK2001: unresolved external symbol "public: thiscall v8::String::AsciiValue?::~AsciiValue?(void)" (??1AsciiValue@String@v8@@QAE@XZ) 1>main.obj : error LNK2001: unresolved external symbol "public: thiscall v8::String::AsciiValue?::AsciiValue?(class v8::Handle<class v8::Value>)" (??0AsciiValue@String@v8@@QAE@V?$Handle@VValue@v8@@@2@@Z) 1>main.obj : error LNK2001: unresolved external symbol "public: static class v8::Local<class v8::String> cdecl v8::String::New(char const ,int)" (?New@String@v8@@SA?AV?$Local@VString@v8@@@2@PBDH@Z) 1>main.obj : error LNK2001: unresolved external symbol "public: thiscall v8::HandleScope?::~HandleScope?(void)" (??1HandleScope@v8@@QAE@XZ) 1>main.obj : error LNK2001: unresolved external symbol "public: thiscall v8::HandleScope?::HandleScope?(void)" (??0HandleScope@v8@@QAE@XZ)

Any help? I'd really like to use this. Thanks!

Comment by sellman69@gmail.com, Apr 30, 2010

Which is the best for google maps & mature gay men porn !

Comment by martin.balazik, May 20, 2010

Hopefully this will help some guys when building on Windows in Visual Studio, there are missing files in the project: dtoa.cc, dtoa.h, fixed-dtoa.h, fixed-dtoa.cc which results in mksnapshot project not being built (failing on unresolved externals). I've added these 4 files to the project and it works.

Comment by raoulmil...@gmail.com, Jul 29, 2010

Awesome. This also works fine in Visual Studio 2010. You just have to modify the path to the vcvarsall.bat appropriately.

Comment by stahlb...@gmail.com, Aug 20, 2010

sphair,

Your comment is perfect for the following setup:
  • Windows 7 64bit
  • Microsoft Visual C++ 2008 Express Edition with SP1
  • Microsoft Windows SDK v7.0
  • Python 2.7
  • Scons 2.0.0.final.0.r5023

NOTE:: As of this writing, if a 64 bit AMD processor is detected by python 2.7, it returns AMD64 for the architecture guess, not amd64. So I modified the tool/utils.py file to add the following under GuessArchitecture?()

    elif id == 'AMD64':

        return 'ia32' 

In all, my correct sequence worked as follows:

From the command line:

set PATH=C:\Python27;C:\Python27\Scripts;%PATH%

"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"

scons env="PATH:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools,INCLUDE:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Include;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include,LIB;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Lib;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib"

Comment by coreyschram@gmail.com, Sep 1, 2010

Well, after hours trying to compile V8 as 32-bit on 64-bit Windows, I found an error in the environment path suggested in this page. There's a semi-colon after LIB, instead of a colon. 6-8 hours of trying to figure out what the hell is wrong, and that was my issue the whole time lol

Here's the environment paths I used: "PATH:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools,INCLUDE:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include,LIB:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib"

Comment by hhho...@gmail.com, Dec 7, 2010

Gawd! Isn't there a place to download it built from the factory.

Comment by sher...@gmail.com, Dec 11, 2010

to build 32bit v8 with windows xp 64 and vs 2010 pro:

open visual studio command prompt (the 32 bit one):

go in v8 directory:

c:\Python25\Scripts\scons.bat env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%" arch=ia32 your_other_options

worked for me

Comment by permaq...@gmail.com, Dec 21, 2010

When I follow the instructions I have no problem building v8.lib on Windows using Visual Studio 2008. Everything just worked, I have v8.lib. When I try to compile the hello world example I get some errors of which the first is:

Compiling... V8Hw?.cpp c:\perforce\users\gprice\ictsrcmain\test\v8hw\v8hw\v8hw.cpp(10) : error C2440: 'initializing' : cannot convert from 'v8::Local<T>' to 'v8::String'

with [
T=v8::String
] No constructor could take the source type, or constructor overload resolution was ambiguous
Obviously I am doing something wrong. Can anyone tell me what? Of course I added #include <v8.h> and using namespace v8 to the code on the web page. I get the same error either inside Visual Studio 8 or using the cl command line in the getting started guide. -Gary Price

Comment by permaq...@gmail.com, Dec 21, 2010

Ah silly me - that code won't run. It's the code underneath it that runs... "To actually make this code run" is the phrase I was missing.

Comment by vkstechn...@gmail.com, Mar 8, 2011

Hi Guys,

I have compiled and build the latest source of V8 using the above procedure fo VC++ and have got a lib file of 200+ MB named v8.lib too.

But whenever I am running I am getting the following error:

E:\vj\V8_3>cl /Iinclude hello_world.cpp v8.lib Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved.

hello_world.cpp Microsoft (R) Incremental Linker Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved.

/out:hello_world.exe hello_world.obj v8.lib v8.lib(api.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performanc e Microsoft (R) Incremental Linker Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved.

/out:hello_world.exe hello_world.obj v8.lib v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impac cept@12 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impli sten@8 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impse nd@16 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impcl osesocket@4 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impfr eeaddrinfo@4 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impti meGetTime@0 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impso cket@12 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impbi nd@12 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impre cv@16 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impse tsockopt@20 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impsh utdown@8 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impnt ohs@4 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impht ons@4 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impWS AGetLastError@0 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impge taddrinfo@16 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impht onl@4 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impnt ohl@4 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impWS AStartup@8 v8.lib(platform-win32.obj) : error LNK2001: unresolved external symbol impco nnect@12 hello_world.exe : fatal error LNK1120: 19 unresolved externals

If someone has any ideas, please help urgently, I need to use it for some work urgently.

Comment by ryan.ger...@gmail.com, Mar 9, 2011

I'm using VC++, and I was able to reduce my V8 lib from 200 MB to 180KB. You have to use the param "library=shared" when you use scons. I'm also dynamically linking against the CRT. This option is briefly described on one of the V8 pages, but it doesn't outline how much of an impact on binary size the option has (http://code.google.com/apis/v8/build.html).

Here is the exact command I used to build to get such a small lib:

scons mode=release library=shared msvcrt=shared env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%"

Comment by ryan.ger...@gmail.com, Mar 11, 2011

Has anybody been able to successfully build a 64-bit DLL of V8 for Windows? I was able to build a static lib, but not the shared library.

I was able to build the 64-bit lib by using an SLN file that I found for V8 in "tools\visual_studio". When I tried switching the "v8_base" and "v8" projects to build a DLL instead of a static LIB, the build started giving me linker errors.

I dug through the SConstruct file to try and determine what build/link switches change when "library=shared" is put into Scons, so that I could setup the same switching in VS. I added the preprocessor definition "BUILDING_V8_SHARED", and made a few other changes, but the linker errors remain.

There are quite a few errors, but the first error is in v8_base:

error LNK2001: unresolved external symbol "private: static int const v8::internal::Snapshot::size" (?size@Snapshot@internal@v8@@0HB) bootstrapper.obj

If anybody can help me with building a 64-bit DLL of V8 on Windows, that would be awesome. Thanks!

Comment by dan.lewi...@gmail.com, Apr 11, 2011

I can't build V8 on Win7 with Python 2.7 and SCons 2.x

Apparently SCons doesn't recognize any 64-bit version of Python?

You know, there are easier ways to build programs. Ones that don't need entire websites and entire other programming languages installed just to compile?

I'd work it out, but I need to be able to compile it to start with.

Comment by dan.lewi...@gmail.com, Apr 11, 2011

Okay, so I installed 32-bit Python just for this project. I encountered another problem on 64-bit windows;

Visual Studio is installed under C:\Program Files (x86)\Microsoft Visual Studio 9.0.

keepin' on truckin'

Comment by teomo...@gmail.com, May 11, 2011

When I am trying to compile like this cl /Iinclude hello_world.cpp v8.lib i get this error LINK : fatal error LNK1104: cannot open file 'kernel32.lib' and when I am trying to do it like this cl /Iinclude v8.lib Winmm.lib WSock32.lib hello_world.cpp ws2_32.lib I am getting this error LINK : fatal error LNK1181: cannot open input file 'Winmm.lib'

how to fix this?

Comment by windj...@gmail.com, Jun 20, 2011

How can I compile v8 with 1 byte struct alignment?

Comment by kris.kra...@gmail.com, Jul 29, 2011

Setup: Windows 7 Professional, 64-bit, VS.NET 2008, Python 2.5, latest scons.

Drop into a VS.NET command window. "cd" over to your v8 directory. Run the following:

scons -j4 arch=x64

Worked just fine.

Comment by r.plant...@gmail.com, Aug 22, 2011

@ coreyschram, Sep 1, 2010 Thanks for posting this comment. I have a brand new PC with i7/2600K and Windows 7. I downloaded the free Visual C++ compiler from Microsoft ("Express"). I didn't get any compiler errors when using the command

scons env="PATH:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin;C:\ Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files\Microsoft Vi sual Studio 10.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\T ools,INCLUDE:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Fil es (x86)\Microsoft SDKs\Windows\v7.0A\Include;C:\Program Files\Microsoft SDKs\Windows\v7.0 A\Include,LIB:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib"

However, the test suite test.py complains with "The file name, directory name or volume label syntax is incorrect" - with no further indication on which part is wrong.

Comment by r.plant...@gmail.com, Aug 23, 2011

I am still unable to run the test suite. My command

python tools/test.py -S env="INCLUDE:%INCLUDE%,PATH:%PATH%,LIB:%LIB%"

gives the error

"The filename, directory name, or volume label syntax is incorrect".

Somehow it comes from the execution of the SCONS command, inside of the script test.py. But even when changing the command by specifying the explicit path in line 728ff. of test.py

def BuildRequirements(context, requirements, mode, scons_flags):
  command_line = (['C:\\Python27\\Scripts\\scons.bat', '-Y', context.workspace, 'mode=' + ",".join(mode)]
                  + requirements
                  + scons_flags)
  output = ExecuteNoCapture(command_line, context)
  return output.exit_code == 0

the results remains unchanged. No idea what's going wrong.

Comment by r.plant...@gmail.com, Aug 23, 2011

Compile HelloWorld?.cpp using Visual Studio 2010 Express Edition

I tried to run the sample HelloWorld?.cpp (situated directly in \V8), as recommended above, using the VS command prompt. But there were libraries missing. Thanks to http://stackoverflow.com/questions/3129211/embedding-v8-with-visual-c-2010, I tried the following cmd line instead:

cl /Iinclude HelloWorld.cpp v8.lib Ws2_32.lib WINMM.lib

And this one worked fine, producing the largest file (>2MB) I ever had to print out "Hello world!" !!!

I wonder how Google is able to place a complete browser, including V8 and thousands of other things, into one executable chrome.exe of only 980 KB. Also, Chrome seems to start quicker than even this HelloWorld?.exe.

Comment by r.plant...@gmail.com, Aug 23, 2011

The test suite now works on my Windows 7 computer, too. I had to modify line 476 in test.py (module RunProcess?):

From

    popen_args = '"' + subprocess.list2cmdline(args) + '"';

to

   popen_args = subprocess.list2cmdline(args);

With other words: Wrapping the command line into double quotes might have been the solution for some other Windows releases, but on Windows 7 this was obstructive.

It then generates the test shell D8.exe, and after that returns to the test runner. The runner needs 8 minutes on my machine to run 6'279 tests in total. The outcome is "100% passed".

Comment by wucd2...@gmail.com, Sep 8, 2011

vc2010 编译不过去,郁闷

Comment by james.mo...@red-gate.com, Sep 25, 2011

SCons has been deprecated. See http://code.google.com/p/v8/wiki/BuildingWithGYP

Comment by Dit.37f1...@gmail.com, Sep 30, 2011

v8preparser.dll : fatal error LNK1120: 8 unresolved externals scons: [v8preparser.dll] Error 1120 scons: building terminated because of errors.

how fix this????

Comment by Dit.37f1...@gmail.com, Oct 1, 2011

with great effort, finally resolved hello_world example .. thanks

newbie

Comment by golgo...@gmail.com, Nov 5, 2011

Could someone please update this document with the correct information? Is V8 even an active project. There is no good documentation available.

Comment by takuna2...@gmail.com, Nov 6, 2011

Memory leaks detected while calling function. Example

Handle<Value> result1 = process->Call(context->Global(), 2,params);

How fix this? Is this my mistake or bug?

Comment by brook.mo...@gmail.com, Nov 29, 2011

I agree with Dan Lewis. VS2008 is already a complete build environment; why would one need Python and Scons to build a C++ project? Somewhere I'm sensing a certain Linux tilt to all this.

Comment by shaba...@gmail.com, Jan 11, 2012

You sound like a fool. This stuff was built in Linux and semi-ported to windows. The develops of these tools apparently don't bother with windows, and look to the community of windows user to provide documentation for getting this kind of CRAPPY setup to work.

I just think that is absolutely stupid that someone did not script or program this shit. Hell could have even included a config file with the proper paths needed for scons env variable. Well, enough ranting, here's my addition to this stupidity.

Using Visual Studio 2010 on Windows 64 bit

Requirements:

Python 2.7.2/32 bit (because scons still doesn't work with Python 3, or 64bit versions of python. Thanks scons, way to avoid the future.) scon 2.1.0 (no Python 3 or 64 bit goodness here, I'm living in the past, here in the future.) Add to your PATH environment variable, either the 'user' or 'system' "C:\Program Files (x86)\Python27;C:\Program Files (x86)\Python27\Scripts" Reboot your PC, or logout, then log back in. Either should work to force windows to reload the PATH environment variable.

Now you can do it the complicated way, or the easy way. I was building this on a cooperate PC, which I only needed to build once, so I took the easy way out. Only after trying the hard way for 4+ hours. We use v8 to run JSLint to check our .js files. Thay is why I had to do it at work.

The Over Complicated Way Which May NOT Work

The setup batch file supplied with Visual Studio 2010, this assumes you installed VS 2010 in the default location:

> "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"

Now V8 can be built by passing the environment variables to SCons.

> scons env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%"

Note: Depending on your setup, PATH, INCLUDE, and LIB may NOT be set, even after running "vcvarsall.bat". So your best bet is to use the line below. Or manually set them up yourself..

The Easy Way Out

Since setting the environment variables is not feasible for crappy patch like this, just specify the paths directly.

> scons.py env="PATH:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools,INCLUDE:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include,LIB:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib" Note: I had to add the .py Oh, my goodness it worked, I built the damn thing on windows, and I did not have to restart my computer to load the environment variables.

Comment by artur.mu...@live.com, Feb 8, 2012

To build on a Windows 8 Dveloper Preview, Just install Microsoft Visual Studio 11 Developer Preview (not Express version, which one is already shipped with the OS build), then create build-vc11-amd64.cmd on a x64 systems as follows:

build-vc11-amd64.cmd


call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\"vcvars64.bat

scons env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%" -j4 arch=x64 mode=debug


Comment by sharath....@gmail.com, Feb 16, 2012

I am getting an error that says do not know to make file target 'files' Any insights??

Comment by v8develo...@gmail.com, Feb 28, 2012

We used the scons method to successfully build the library for Visual Studio 2010 and the simple example worked OK.

However when we tried to integrate the library into our real application we ran into problems with an ITERATOR_DEBUG_LEVEL mismatch. Rather than try to find a solution to this via the scons approach, we decided to integrate the v8 source files into a new VS2010 library project. And it seems to work!

We picked up the C++ options from the scons console output.

The final hurdle was overcome when we realised that the scons build was creating two C++ files on the fly from javascript files. So be sure to include /obj/libraries.cc and /obj/experimental-libraries.cc in the vc2010 project.

Comment by Net...@gmail.com, Mar 2, 2012

Here are instructions for compiling with MinGW/MinGW-w64, Python 2.7.2 (32-bit) and scons 2.1.0:

set PATH=C:\Python27;C:\Python27\Scripts;%PATH%

32-bit:
scons mode=debug arch=ia32 library=shared toolchain=gcc importenv=PATH -j8
scons mode=debug arch=ia32 library=static toolchain=gcc importenv=PATH -j8
scons mode=release arch=ia32 library=shared toolchain=gcc importenv=PATH -j8
scons mode=release arch=ia32 library=static toolchain=gcc importenv=PATH -j8

64-bit:
scons mode=debug arch=x64 library=shared toolchain=gcc importenv=PATH -j8
scons mode=debug arch=x64 library=static toolchain=gcc importenv=PATH -j8
scons mode=release arch=x64 library=shared toolchain=gcc importenv=PATH -j8
scons mode=release arch=x64 library=static toolchain=gcc importenv=PATH -j8

Change -j8 as appropriate for number of threads you want to compile with.


Sign in to add a comment
Powered by Google Project Hosting