1

我刚刚使用 Visual Studio 2012 在 Windows 8 上完成了 V8 的构建,现在我想将它静态链接到应用程序

除了我不知道从这里去哪里我从谷歌得到了一些我想尝试编译的代码

#include <v8.h>

using namespace v8;

int main(int argc, char* argv[]) {
  // Get the default Isolate created at startup.
  Isolate* isolate = Isolate::GetCurrent();

  // Create a stack-allocated handle scope.
  HandleScope handle_scope(isolate);

  // Create a new context.
  Handle<Context> context = Context::New(isolate);

  // Here's how you could create a Persistent handle to the context, if needed.
  Persistent<Context> persistent_context(isolate, context);

  // 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();

  // The persistent handle needs to be eventually disposed.
  persistent_context.Dispose();

  // Convert the result to an ASCII string and print it.
  String::AsciiValue ascii(result);
  printf("%s\n", *ascii);
  return 0;
}

我知道如果我尝试在做其他事情时包含 v8 标头,它只会带来编译错误,这就是我想知道的,

我很抱歉没有提供信息,老实说,我不完全确定需要什么来帮助解决我的问题,所以对此的任何评论也很感激

4

0 回答 0