This document introduces some key V8 concepts and provides a
hello world example to get you started with V8 code.
First, some key concepts you will need:
These concepts are discussed in greater detail in the [[Embedder‘s Guide|Embedder’s Guide]].
Follow the steps below to run the example yourself:
git checkout refs/tags/7.1.11 -b sample -t
tools/dev/v8gen.py x64.release.sampleYou can inspect and manually edit the build configuration by running
gn args out.gn/x64.release.sample
ninja -C out.gn/x64.release.sample v8_monolith
hello-world.cc, linking to the static library created in the build process. For example, on 64bit Linux using the GNU compiler:
g++ -I. -Iinclude samples/hello-world.cc -o hello_world -lv8_monolith -Lout.gn/x64.release.sample/obj/ -pthread -std=c++0x
cp out.gn/x64.release.sample/icudtl.dat .
hello_worldexecutable file at the command line. e.g. On Linux, in the V8 directory, run:
Of course this is a very simple example and it‘s likely you’ll want to do more than just execute scripts as strings! For more information see the [[Embedder‘s Guide|Embedder’s Guide]]. If you are looking for an example which is in sync with master simply check out the file