neon: [docs] Electron apps - undefined symbol __cxa_pure_virtual

Hey, I’m learning how to set up neon here, and I’m running into an issue where, upon launching electron, I get the error: undefined symbol: __cxa_pure_virtual.

FWIW, I followed the documentation here. I found #194, but I’ve interpreted it as the ticket for integrating with electron-rebuild, and that the electron-build-env process was already functional? 🤔 😄

To reproduce:

  1. git clone https://github.com/electron/electron-quick-start
  2. cd electron-quick-start
  3. npm i neon-hello
  4. npm i electron-build-env neon-cli --save-dev
  5. $(npm bin)/neon build neon-hello
  6. Edit main.js, adding require('neon-hello') to the top
  7. npm start
$ npm start                                         

> electron-quick-start@1.0.0 start /home/mitch/dev/electron-quick-start
> electron .

App threw an error during load
Error: /home/mitch/dev/electron-quick-start/node_modules/neon-hello/native/index.node: undefined symbol: __cxa_pure_virtual
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:160:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/mitch/dev/electron-quick-start/node_modules/neon-hello/lib/index.js:1:168)
    at Object.<anonymous> (/home/mitch/dev/electron-quick-start/node_modules/neon-hello/lib/index.js:5:3)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: /home/mitch/dev/electron-quick-start/node_modules/neon-hello/native/index.node: undefined symbol: __cxa_pure_virtual
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:160:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/mitch/dev/electron-quick-start/node_modules/neon-hello/lib/index.js:1:168)
    at Object.<anonymous> (/home/mitch/dev/electron-quick-start/node_modules/neon-hello/lib/index.js:5:3)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

If someone is interested, I solved the issue by doing what someone did in this post : https://users.rust-lang.org/t/neon-electron-undefined-symbol-cxa-pure-virtual/21223

#[no_mangle]
pub extern fn __cxa_pure_virtual() {
    loop{};
}

I added this piece of code in my native/src/lib.rs file, rebuilt the project, and it worked for me.

Re-opening this issue. It is not a duplicate. It’s caused by a missing .cpp(true) when building neon-runtime. It should be fixed in an upcoming PR to resolve several electron issues.

@fominok Happened to me when I didn’t build with electron-build-env - doing so resolves it for me (in combination with the workaround from @MeryllEssig).

@mitchhentges electron comes with a chromium to render the content, no worries. I don’t have the time to test the issue currently (currently moving into a new flat) if i find some time at work i will try it though.

@adityapk00 That’s likely an issue in the examples repo (for example, it’s using an older cli version). Can you open an issue there? Thanks!

@kjvalencik thank you for the fast reply I’ve tried to build this example and have failed with ‘lib/cli.js’ not found error on npm i and different node versions error. I’m new to Node and build steps for this example would be very helpful for me Had to replace node ../lib/cli.js to neon and everything goes fine, thanks!

Yes, it should be fixed. There is an electron test that can be used as an example. The rust neon crate needed to be bumped as well.

https://github.com/neon-bindings/neon/tree/master/test/electron

Well I’ve tried solution with defining missing fn as suggested by @MeryllEssig but now it has undefined symbols like _ZN12v88Function3… and so on

@mitchhentges the versions for the current electron-quickstart should be the follwing, since you use node 11.9.0 could you try to use node 10.11.0 when building instead.

Electron 4.0.4
Node 10.11.0
Chromium 69.0.3497.106

Does the example work for you?