out-of-date document hurts

The headache of building google V8 Javascript Engine

We have a project which would make use of the google V8 engine to parse and execute javascript.

I followed the downloading and building V8 doc and successfully built v8 library. However, I failed to follow “Getting Started” guide to compile the hello world example.

g++ -Iinclude -pthread -o hello_world hello_world.cc lib64/libicudata.a lib64/libv8_base.x64.a lib64/libv8_nosnapshot.x64.a lib64/libv8_snapshot.a
hello_world.cc: In function 'int main(int, char**)':
hello_world.cc:23:27: error: 'New' is not a member of 'v8::String'
hello_world.cc:32:22: error: 'class v8::Persistent' has no member named 'Dispose'
hello_world.cc:35:3: error: 'AsciiValue' is not a member of 'v8::String'
hello_world.cc:35:22: error: expected ';' before 'ascii'
hello_world.cc:36:19: error: 'ascii' was not declared in this scope
make: *** [hello_world] Error 1

I am sure that this has nothing to do with library, it may be caused by prototype mismatch. But why failed? I trusted the docs, it should work!

After several hours of experiment and googling, I gave up. tried to checkout an older version instead(here I checked out version from svn tag http://v8.googlecode.com/svn/tags/ Compile the example ode again, everything works like magic!

Note, when build the lastest version(currently 3.24.5), you may also encounter error like this:

make[1]: Entering directory `/home/curu/src/v8/out'
  CXX(target) /home/curu/src/v8/out/x64.release/obj.target/v8_base.x64/src/hydrogen.o
cc1plus: warnings being treated as errors
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_algo.h: In member function 'void v8::internal::HOptimizedGraphBuilder::HandlePolymorphicCallNamed(v8::internal::Call*, v8::internal::HValue*, v8::internal::SmallMapList*, v8::internal::Handle)':
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_algo.h:2178: error: array subscript is above array bounds
make[1]: *** [/home/curu/src/v8/out/x64.release/obj.target/v8_base.x64/src/hydrogen.o] Error 1
make[1]: Leaving directory `/home/curu/src/v8/out'
make: *** [x64.release] Error 2

We can see that the error information is related to gcc itself, update GCC to 4.6 should solve this prolem.

The out-of-date document hurt me a lot. Great software should come with great and up-to-date document, espically for Open Source Software.

This entry was posted in Programming and tagged , . Bookmark the permalink.

3 Responses to out-of-date document hurts

  1. santosh Mahto says:

    I also faced same issue.
    Thanks for pointing the issue and fix

  2. santosh Mahto says:

    It will work if you build v8 by using below command.

    make native -j8 component=shared_library console=readline liveobjectlist=on snapshot=off

  3. liangmingyi says:

    @santosh Mahto
    What’s the reason?

Leave a Reply