第一個V8程式
一個官方的hello world,http://code.google.com/apis/v8/get_started.html
#include using namespace v8;int main(int argc, char* argv[]) { // Create a stack-allocated handle scope. HandleScope handle_scope; // Create a new context. Persistent<Context> context = Context::New(); // Enter the created context for compiling and // running the hello world script. Context::Scope context_scope(context); // Create a string containing the JavaScript source code. Handle<String> source = String::New("'Hello' + ', World!'"); // Compile the source code. Handle<Script> script = Script::Compile(source); // Run the script to get the result. Handle<Value> result = script->Run(); // Dispose the persistent context. context.Dispose(); // Convert the result to an ASCII string and print it. String::AsciiValue ascii(result); printf("%s/n", *ascii); return 0;}
將如上代碼拷貝到你用的版本的vs裡,設定好include目錄,以及引入lib檔案,並且將之前你產生的dll放入相應debug或者release目錄下,就可以正確編譯並執行了。