|
BuildingOnWindows
Detailed instructions for building V8 on Windows.
Building on WindowsAfter 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 2005SCons 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 LibraryThe 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 generationThe 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 2008As 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 following example passes these paths for a Visual Studio 2008 installation assuming that the default installation directories have been used.
Using Visual C++ Express 2008As for Visual Studio 2008 SCons alos does not detect Visual C++ Express 2008 and the env options 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.
Running tests on WindowsWhen 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.
When running tests turning off link-time code generation will reduce link time significally. This is useful when running the tests repeatedly.
Building the hello_world sample on WindowsTo 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. |
Sign in to add a comment
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
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
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.
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"
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:
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.
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.
I had exactly the same problem.
I added Winmm.lib to the linker and it works.
(Hope it helps)
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!
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!
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"
Linking winmm.lib and WSock32.lib should be added to the actual instruction.
is it possible to build v8 on mingw on windows?
I whant to build V8 under gcc-cygwin enviroment, is it possible ?
nice
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...
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\typeinfo(160) : warning C4275: non dll-interface class 'stdext:: exception' used as base for dll-interface class 'std::bad_typeid' scons: obj\debug\mksnapshot.obj? Error 2 scons: building terminated because of errors.D:\Development\thirdparty\v8>
Any ideas?
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
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?
Anyone to put statically linked version somewhere? I cant build it too.
Has anyone tried to used the Intel 11.x compiler?