Neon + electron: "undefined symbol: __cxa_pure_virtual"


#1

Hi folks,

I’m trying out neon to build a Node.js module in Rust. Compiling, and require()'ing and running my hello world function from a node console work fine. As a next step, i tried to require() it from an electron app’s browser window (via the developer tools). However, I get the following error:
https://paste.rs/xaF

Here are my package.json files for both projects (the electron app (electest) and the node.js module written in rust with neon (test)): https://paste.rs/3gG.js

My system is an x86_64 running Arch Linux. I don’t understand what is happening here and I’d appreciate any hint in the right direction.

Regards :slight_smile:
mmmmib


#2

Ok, so i kind of solved it, even though i don’t really understand why this happened in the first place. I included the following code in my rust library:

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

Apparently, this __cxa_pure_virtual is some kind of C++ error handler when dynamic dispatch fails, which should never happen. After adding that code, i removed and re-added the dependency from the electron project’s node_modules directory, ran npm run-script build and now i can require() the module from the electron browser window and run its functions.


#3

__cxa_pure_virtual is defined in the C++ standard library, you get this error when using C++ functionality but not linking against that

what the function does is print pure virtual method called and call std::terminate() so if this is the only function you’re missing i guess you can’t go wrong with defining it yourself


#4

Ok, thanks

although it is kind of weird that this needs to be in my library when i have no additional c++ dependencies and the electron/chromium that’s loading it is probably already linking against the c++ standard library.


#5

i don’t know if such a transitive dependency is acceptable for the dynamic linker—

anyhow, if you’re not using C++ yourself, my guess is that neon does, as this already happens with a hello world it makes sense to report a bug against that crate