#include <tchar.h>
#include <node.h>
namespace demo {
using v8::Exception;
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Number;
using v8::Object;
using v8::String;
using v8::Value;
// This is the implementation of the "add" method
// Input arguments are passed using the
// const FunctionCallbackInfo<Value>& args struct
void Method(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
v8::Local<v8::ArrayBuffer> jsobj = v8::ArrayBuffer::New(isolate, 10);
memset(jsobj->GetBackingStore()->Data(), 0, 10);//has linking error
args.GetReturnValue().Set(jsobj);
}
void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "hello", Method);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
} // namespace demo
My addon use function from STL,I want to run it in electron. so I need to rebuild it with libc++. Here is how I use:
Failed log:
Here is the demo: binding.gyp:
addon.cc: