#include <v8.h>
#include <libplatform/libplatform.h>
#include <stdlib.h>
#include <string.h>
using namespace v8;
int main(int argc, char* argv[]) {
// Initialize V8.
//v8::V8::InitializeICU();
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
V8::Initialize();
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
// Create a new Isolate and make it the current one.
Isolate* isolate = v8::Isolate::New(create_params);
v8::Persistent<v8::String> test;
{
Isolate::Scope isolate_scope(isolate);
// Create a stack-allocated handle scope.
HandleScope handle_scope(isolate);
// Create a new context.
Local<Context> context = Context::New(isolate);
// Enter the context for compiling and running the hello world script.
Context::Scope context_scope(context);
Local<String> local_value = String::NewFromUtf8(isolate, "test");
v8::MaybeLocal<v8::Promise::Resolver> maybe_local_resolver = v8::Promise::Resolver::New(context);
v8::Local<v8::Promise::Resolver> local_resolver = maybe_local_resolver.ToLocalChecked();
local_resolver->Resolve(context, local_value);
local_resolver->Resolve(context, local_value);
}
// Dispose the isolate and tear down V8.
isolate->Dispose();
V8::Dispose();
V8::ShutdownPlatform();
return 0;
}
ROOT=/usr/local/opt/v8@6.6
LIB_DIR=$ROOT/lib/
SRC_DIR=$ROOT
INCLUDE_DIR=$ROOT/include
g++ hello_world.cpp -o hello_world \
-Wno-unused-result \
-g \
-O2 \
-std=c++14 \
-I$SRC_DIR \
-I$INCLUDE_DIR \
-L$LIB_DIR \
-lv8_libbase \
-lv8_libplatform \
-lv8 \
-lpthread
install_name_tool -add_rpath $LIB_DIR hello_world
$ ./hello_world
Received signal 11 SEGV_MAPERR 00000000000a
==== C stack trace ===============================
[0x000106d8ff14]
[0x7fff6ca6bf5a]
[0x0001072d0984]
[0x000106de95e8]
[0x000106d79bb2]
[0x7fff6c7ea115]
[0x000000000001]
[end of stack trace]
Segmentation fault: 11
--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.