UPDATE [12/17/2011]: Use of SCons to build v8 is deprecated. Using Gyp instead was surprisingly straightforward. Here are the commands I ran:
c:\d\projects\v8>"c:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /x86 /Release c:\d\projects>svn co -q http://v8.googlecode.com/svn/trunk/ v8 c:\d\projects>cd v8 c:\d\projects\v8>svn co -q http://gyp.googlecode.com/svn/trunk build/gyp c:\d\projects\v8>svn co -q http://src.chromium.org/svn/trunk/deps/third_party/cygwin@66844 third_party/cygwin c:\d\projects\v8>svn co -q http://src.chromium.org/svn/trunk/tools/third_party/python_26@89111 third_party/python_26 c:\d\projects\v8>third_party\python_26\python.exe build\gyp_v8 -G msvs_version=2010 Updating projects from gyp files... c:\d\projects\v8>build\all.sln
If you’re following along at home, you’ll probably want to leave off the -q option to svn. I just used it to keep the output short. It’s also not strictly necessary to include the initial SetEnv.Cmd invocation. I put it there to make it explicit that these instructions are for a 32-bit build. (I was unsuccessful in generating an x64 build. It doesn’t seem to be entirely supported[?])
One last remark: I built with Visual Studio Express 2010, so I got a bunch of errors about solution folders not being supported in this version of Visual Studio. Once I clicked through all the message boxes, I was able to build the v8 lib just fine.
END UPDATE
You need a couple of things before beginning:
-
Python 2.4 or later. I chose to install ActivePython 2.7.1 for x86. I went with the 32-bit version even though my machine is 64-bit because the automatic installer for SCons doesn’t find Python otherwise, and I didn’t feel like doing a manual install.
-
SCons 1.0.0 or later. I downloaded the automatic installer scons-2.1.0.alpha.20101125.win32.exe from SourceForge because I was too lazy to download the raw archive and do a python setup.py install. (Aside: There are Visual Studio project files in the tools/visual_studio folder of the v8 source; however, they don’t appear to get a lot of love. I got errors when I tried to build d8 with them, so I decided to focus on using the ‘official’ build tool instead.)
-
Visual C++ 2010 Express. (Technically, this is optional if you simply want to build V8. SCons only uses the command line compiler, which is bundled with the Windows SDK.)
-
The Windows SDK For Windows 7 And .NET Framework 4 v7.1. I used this link, but YMMV.
-
The v8 source code. I downloaded the trunk using the command:
svn checkout http://v8.googlecode.com/svn/trunk/ v8
Once you get that mess of stuff downloaded/installed, compilation is pretty straightforward. To build a 32-bit version of the v8 lib, use these commands:
c:\d\v8>"c:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /x86 /Release c:\d\v8>scons arch=ia32 env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%" \ library=shared mode=release msvcrt=shared -j4
To build a 64-bit version, use these commands instead:
c:\d\v8>"c:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /x64 /Release c:\d\v8>scons arch=x64 env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%" \ library=shared mode=release msvcrt=shared -j4
If you want to build the d8 developer’s shell (recommended), re-run the scons command with d8 tacked onto the end, right after –j4.
NOTE: the 64-bit version failed to build for me unless I removed /WX from WARNINGFLAGS in the SConstruct file. Here’s a trivial patch to show what I changed:
Index: SConstruct
===================================================================
--- SConstruct (revision 7351)
+++ SConstruct (working copy)
@@ -328,7 +328,7 @@
},
'msvc': {
'all': {
- 'WARNINGFLAGS': ['/W3', '/WX', '/wd4351', '/wd4355', '/wd4800']
+ 'WARNINGFLAGS': ['/W3', '/wd4351', '/wd4355', '/wd4800']
},
'library:shared': {
'CPPDEFINES': ['BUILDING_V8_SHARED'],
Be forewarned, though: I think the warning that was being treated as an error with the /WX flag enabled might actually have been a ‘real’ error. I created a ticket for this in v8’s issue tracker but there’s been no response yet. [Update: This did turn out to be a bug, but it had already been fixed by the time I reported it. Note to Self: check issues against http://v8.googlecode.com/svn/branches/bleeding_edge/ next time before opening a ticket…]
When the build completes, you’ll want to manually ‘install’ v8 by copying the following items to wherever it is you want them to ultimately live:
- The entire include folder
- v8.lib
- v8.dll
- d8.exe (if you built it)
(There might be a way to install using SCons, but I’m not smart and/or patient enough to figure it out.)
One ‘extra for experts’ that I’d like to investigate is: how to build d8 with readline support. There is some rudimentary history support even without it (on Windows, at least), so I’m not sure what benefit it would provide. I’ll update this post if/when I get around to figuring that out…



{ 6 comments… read them below or add one }
When I build, it seems to build v8.lib and v8.dll fine, but when building v8preparse.lib it fails. Do I need v8preparser.lib in order to create the “Hello World” sample? Also, when I try to run the “Hello World” sample, I get linker errors when linking to v8.lib.
Things seem to have changed since my original post. I updated to the latest trunk (as of today) and tried to build the x64 version as outlined above. I get the same error you described, see http://pastebin.com/p0sHnryk for the compiler output.
I’ll see if I can figure out what’s wrong, and maybe submit a bug report if it hasn’t been fixed already on bleeding_edge. Thanks for your comment!
I couldn’t see any ‘obvious’ fix for the issue reported by @Josh Bodily (and confirmed by me), so I went ahead and opened a defect report here:
– http://code.google.com/p/v8/issues/detail?id=1596
Thx for repro-ing that. That was the same output I was seeing too. I was able to work around the issue by building with “library=static” and then building again twice as “library=shared”. Otherwise, you’re post was very helpful, thx for that.
Hopefully the maintainers get that sorted out. I voted for the ticket you opened.
I’m also on Win 7, and I don’t have VS installed (but Win 7 SDK). So can I built V8?
@Andre, this is unconfirmed speculation based on a quick web search, but: it seems to me that gyp does not support building with only the Win 7 SDK installed. I’m pretty sure you need to download/install Visual C++ Express, too. (Or else build using cygwin, which I haven’t tried.)
If you decide to install VC++ 2010 Express, you might want to read this:
– http://support.microsoft.com/?kbid=2519277
If you do install VC++2010 Express, you should probably download/install VS2010 SP1, too. But that will likely disable the 64-bit compilers in the SDK. The KB article linked above explains how to get them back.
{ 1 trackback }