Native Node Addon Dependency Not linking inside Electorn


Hi, I m trying to develop a native node addon with OpenCV (C++ library)as a dependency. while running addon in node command line everything works fine. But as soon as I use that addon inside electron it’s throwing an error or crashing.
I m trying to use an OpenCV function which uses FFMPEG or GStreamer to get video. some time’s error indicates that FFmpeg library is not available inside the electron.
How is running Native node module inside electron is different from running in command line?. I m specifying all required dependent c++ libraries in binding. gyp file.
As mentioned already everything works fine in cmd line but not electron. Any help in this regard is much appreciated.


Electron uses a slightly different ABI (application binary interface) than vanilla Node.js, so you need to recompile native dependencies against the right headers for your Electron runtime. Here’s the documentation about this:

Mentioned in here is a utility that might make this easier for you, depending on your specific build setup:

As an example of how you can include this, @atom/watcher, which is a native node module that’s intended for use within Atom, specifies electron-rebuild as a devDependency and uses a package.json run script as an entry point:


Thanks for the reply. I already used electron-rebuild.
"electron-rebuild": "^1.8.2",

command used to build my addon


I got the same above mentioed I tried a version of vanilla nodejs same as that of electron’s. still it’s not working.



electron-rebuild accepts an argument to determine the target Electron version. Are you certain that it matches… ? I’m reaching a little here.

What’s the specific error message that you see? Or can you find any more information about the crashes, like a stack trace with WinDbg?


I tried multiple things

  1. vanilla nodejs 10.2.0(which was used by the latest stable version of the electron) has a header file issue for native’s only fixed in 10.2.1 so I cannot use that to match target electron version I used 10.2.1 and used electron-rebuild to compile it to match electron’s 10.2.0

  2. I tired with node version 10.11.0 along with the latest nightly build of electron 4(which also uses 10.11.0)

I use a c++ library (OpenCV) in electron .this library, in turn, has a transitive dependency which I mentioned in binding. gyp file. when I check the linked libraries for my .node file all my dependencies are linked properly
ldd my node.addon and as mentioned it running in vanilla nodejs. But in electron, it’s crashing

I am getting an error that one of my dependent libraries FFMPEG is not is installed and linked with my addon.only inside electron I m getting this error

Unable to stop the stream: Inappropriate ioctl for device

I don’t know how to get stack trace in ubuntu. can suggest a tool/library for Linux like WinDbg?


Oh! Interesting. You aren’t seeing a crash on load, but a crash during use that doesn’t manifest from node. I also have no idea why I assumed you were on Windows. Crossing contexts in my head I think.

can suggest a tool/library for Linux like WinDbg?

You could run the process under a C++ debugger like lldb or gdb. There is a substantial learning curve though I’m afraid.

You can also get stack traces from native crashes by creating a core file:

ulimit -c unlimited

Once you have a core file from the crash, you can load it into gdb and get the stack trace that way:


Thanks, Ash Wilson. Let me try this out. it’s weird how the same code is working in native nodejs, not the electron.