Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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;
- }
- test.cc:(.text+0x1a): undefined reference to `v8::Isolate::GetCurrent()'
- test.cc:(.text+0x34): undefined reference to `v8::HandleScope::HandleScope(v8::Isolate*)'
- test.cc:(.text+0x69): undefined reference to `v8::Context::New(v8::Isolate*, v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)'
- test.cc:(.text+0xca): undefined reference to `v8::V8::GlobalizeReference(v8::internal::Isolate*, v8::internal::Object**)'
- test.cc:(.text+0x101): undefined reference to `v8::Context::Enter()'
- test.cc:(.text+0x115): undefined reference to `v8::Isolate::GetCurrent()'
- test.cc:(.text+0x12b): undefined reference to `v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)'
- test.cc:(.text+0x16e): undefined reference to `v8::Script::Compile(v8::Handle<v8::String>, v8::ScriptOrigin*, v8::ScriptData*, v8::Handle<v8::String>)'
- test.cc:(.text+0x192): undefined reference to `v8::Script::Run()'
- test.cc:(.text+0x1da): undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
- test.cc:(.text+0x1fe): undefined reference to `v8::String::AsciiValue::AsciiValue(v8::Handle<v8::Value>)'
- test.cc:(.text+0x229): undefined reference to `v8::String::AsciiValue::~AsciiValue()'
- test.cc:(.text+0x243): undefined reference to `v8::Context::Exit()'
- test.cc:(.text+0x252): undefined reference to `v8::HandleScope::~HandleScope()'
- test.cc:(.text+0x270): undefined reference to `v8::String::AsciiValue::~AsciiValue()'
- test.cc:(.text+0x28f): undefined reference to `v8::Context::Exit()'
- test.cc:(.text+0x2ab): undefined reference to `v8::HandleScope::~HandleScope()'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement