node.js - Undefined symbol when Calling function in C++ Random Char added -
in nodejs i'm building interface shared object in c. have following code:
#include <node.h> #include "libcustom_encryption.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; // // implementation of "add" method // input arguments passed using // const functioncallbackinfo<value>& args struct // void devicegetversion(const functioncallbackinfo<value>& args) { char ver[10] = {0}; unsigned int ver_size = 0; device_get_version(ver, ver_size); isolate* isolate = args.getisolate(); // // 1. save value in isolate thing // local<value> str = string::newfromutf8(isolate, "test"); // // 2. set return value (using passed in // functioncallbackinfo<value>&) // args.getreturnvalue().set(str); } void init(local<object> exports) { node_set_method(exports, "devicegetversion", devicegetversion); } node_module(addon, init) }
node-gyp configure
: worksnode-gyp build
: worksld_library_path=libs/ node index.js
: doesn't work
i following error:
node: symbol lookup error: /long_path/build/release/app.node: undefined symbol: _z18device_get_versionpcs_phj
the when function called gets prepended , appended random characters. i'm assuming random data noise memory. seams if size brakes call function bigger should.
i'm not experienced mixing c++ , c, love explanation on happening hear.
tech specs:
- gcc version: gcc version 4.8.5 20150623 (red hat 4.8.5-4) (gcc)
- nodejs version: v6.2.0
the function called gets prepended , appended random characters
it called name mangling happens in c++.
the actual error here compiled module can not link function device_get_version()
.
your possible actions:
- add implementation of
device_get_version
module - properly link function
- simply remove line , error disappear
upd.
device_get_version
may c function treated c++ function (you can tell mangled name has). make sure function declared
extern "c" { void device_get_version(...); }
Comments
Post a Comment