Problems with my Native C++ Addon in Electron

163 views
Skip to first unread message

Vicent Vidal

unread,
Jan 9, 2019, 10:48:04 AM1/9/19
to nodejs
Recently I developed my first native C++ Addon for node that works fine with my node project (node version 10.15.0)
The Addon has been built using XCode, which project has been generating using CMake.

I´m having the following error when I use the very same native C++  addon from my Electron app.

dyld: lazy symbol binding failed: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE
  Referenced from: /Users/vicentvidal/Documents/Desarrollo/DASNet2/dasaudio/build/DASNetAddon.node
  Expected in: flat namespace
dyld: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE
  Referenced from: /Users/vicentvidal/Documents/Desarrollo/DASNet2/dasaudio/build/DASNetAddon.node
  Expected in: flat namespace


As I can see the problem appears just when I call from my Electron App

const addon = require('bindings')('DASNetAddon');
 
which call the following C++ code

static NAN_MODULE_INIT(Init) {
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
tpl->SetClassName(Nan::New("StreamingWorker").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(2);

        SetPrototypeMethod(tpl, "sendToAddon", sendToAddon);
        
constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(target, Nan::New("StreamingWorker").ToLocalChecked(),
Nan::GetFunction(tpl).ToLocalChecked());
}

My Electron version is 3.0.10
My Nan version 2.12.1
My bindings version 1.3.1

Does anybody has any suggestion?

Thank you in advance

Mikkel Wilson

unread,
Jan 10, 2019, 6:49:56 PM1/10/19
to nodejs
I've had a similar problem with C++ addons. In one instance I had to change libraries ('iltorb' compression library) and in the other I had to use emscripten to transpile the C++ code into javascript so the V8 engine could use directly. It doesn't feel like a solution as much as a workaround, but it does work.

Mikkel

Christopher Jones

unread,
Jan 22, 2019, 9:02:14 PM1/22/19
to nodejs

On Thursday, January 10, 2019 at 2:48:04 AM UTC+11, Vicent Vidal wrote:
Recently I developed my first native C++ Addon for node that works fine with my node project (node version 10.15.0)
The Addon has been built using XCode, which project has been generating using CMake.

I´m having the following error when I use the very same native C++  addon from my Electron app.

dyld: lazy symbol binding failed: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE
  Referenced from: /Users/vicentvidal/Documents/Desarrollo/DASNet2/dasaudio/build/DASNetAddon.node
  Expected in: flat namespace
dyld: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE
  Referenced from: /Users/vicentvidal/Documents/Desarrollo/DASNet2/dasaudio/build/DASNetAddon.node
  Expected in: flat namespace

 
Have you tried compiling from source in Electron, i.e. using its version of V8?

We've seen users of our add-on face the same problem.  There is one user solution at https://github.com/n-riesco/oracledb-electron-builder that may give you ideas.
Reply all
Reply to author
Forward
0 new messages