Compiling Google's V8 Javascript Engine

Lately, I have been playing around with the V8 Javascript engine from Google. I have some ideas of a project I wanted to tinker with, but I will save that for a later post.

Before I could even start playing with it in a project, I needed to compile. This proved to be a bit of a confusing task. Especially, since I have very little C++ experience, and even less experience compiling C++ applications. After lots of Googling and playing around, I finally got it to compile. It seemed best to record my efforts here for future reference and in the case it may help anyone else trying to do the same. By the way, I am on Windows 8 and using Powershell.

A lot of these steps come from Google's V8 website.

Getting the code

So, the first step is to get the code and prerequisites. There are a few things you will need to do first:

Install the following:

Clone the git repo:

git clone git://github.com/v8/v8.git

Check out the chromium python to third_party folder:

svn co http://src.chromium.org/svn/trunk/tools/third_party/[email protected] third_party/python_26

Check out Chromium provided cygwin:

svn co http://src.chromium.org/svn/trunk/deps/third_party/[email protected] third_party/cygwin

Check out Chromium ICU:

svn co https://src.chromium.org/chrome/trunk/deps/third_party/icu46 third_party/icu

Building

Generate the project files. If you already have Python installed and in your PATH, you can run python build\gyp_v8. Or, you can use the Python just downloaded in the third_party folder. third_party/python_26/python.exe build\gyp_v8. I added the -Dtarget_arch=x64 argument to the end of the command to build so I can build 64-bit binaries.

Now, in the Build folder, open the all.sln file in your Visual Studio. I am using VS 2013.

Or, if you want to use the command line, you can run:

"c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" /build Release build\All.sln

That should be it. Visual Studio will place the compiled libraries in the build\Release\lib folder. You can link these libraries when embedding V8 into your application.