Compile c++ library using node 12+

Hi Everyone,
I am not a conversant c++ user, however, I have used this library before (https://github.com/nukedzn/node-tcl) using node 8 and currently its maintainer has not attended to it and does not compile with node 12+. It gives some deprecated errors.
Would anyone be kind to help me change the library so that it compiles. From what I can see only a few errors come up and they may be very trivial to someone who is familiar with c++.

I appreciate your feedback.
list the errors, is a good start...
Sure thing, thank you for your reply.

Here they are, you can reproduce these errors if you download the npm library from about github site and using node 12+ execute
npm install

> node-gyp rebuild

CXX(target) Release/obj.target/tcl/src/tclbinding.o
../src/tclbinding.cpp:61:38: error: too few arguments to function call, single argument 'context' was not specified
constructor.Reset( tpl->GetFunction() );
~~~~~~~~~~~~~~~~ ^
/Users/user/Library/Caches/node-gyp/12.13.0/include/node/v8.h:5995:3: note: 'GetFunction' declared here
V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
^
/Users/user/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
^
../src/tclbinding.cpp:62:76: error: too few arguments to function call, single argument 'context' was not specified
exports->Set( Nan::New( "TclBinding" ).ToLocalChecked(), tpl->GetFunction() );
~~~~~~~~~~~~~~~~ ^
/Users/user/Library/Caches/node-gyp/12.13.0/include/node/v8.h:5995:3: note: 'GetFunction' declared here
V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
^
/Users/user/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
^
../src/tclbinding.cpp:222:13: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations]
r_array->Set( i, Nan::New< v8::String >( Tcl_GetString( objv[i] ) ).ToLocalChecked() );
^
/Users/user/Library/Caches/node-gyp/12.13.0/include/node/v8.h:3411:3: note: 'Set' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version",
^
/Users/user/Library/Caches/node-gyp/12.13.0/include/node/v8config.h:311:29: note: expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated(message)))
^
1 warning and 2 errors generated.
make: *** [Release/obj.target/tcl/src/tclbinding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/user/.Trash/node-tcl-master
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tcl@2.4.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tcl@2.4.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
/Users/user/Library/Caches/node-gyp/12.13.0/include/node/v8.h

is this a c++ header file?

I don't want to install a gazillion things to get to the point you are at.. esp on my work pc...

it looks like *something* in the js is trying to call the c++ but missed a parameter.
if you can get the js to provide that, it may just work (or it may spawn 20 more problems).

if it was working before, and isnt now, its probably not a missing param inside the actual c++ code, in other words. Could be something broken in the build / make for the .o file though...

its one or the other -- js calling wrong or build of the c++ isnt quite right...
Last edited on
Thank you for your reply.

There is no js calling as yet. I tend to agree with you that it is the latter. Some thing to do with the build of c++. Because when you npm install it compiles and builds the .o files in the build directory. This is the step that is failing.

Building the same code using a lower version of node produces no errors and the build directory is complete to be used at runtime by js.

The library is pretty small around 85K and 24MB when npm install downloads the node_modules.

It would be really appreciated if one can download and attempt to compile to see the build errors.
I won't promise to set all that up. I may, but its not doable @ work and @ home depends on what my wife has in mind for me to do over the weekend!

but if you can figure out exactly how node is trying to compile the c++ (the generated makefile or g++ command or whatever it is doing) and post that, it would tell us a LOT about what is going on.
Last edited on
Thanks again for your reply Jonnin and I wish you and your family a great weekend.

From my experience, npm libraries can be pure javascript or can have some c/c++ code to extend nodejs. Using node-gyp you can build for the target version of node js. This library was targeting older version up to 8. https://www.npmjs.com/package/node-gyp

as shown above, when npm install is done inside the library directory it downloads the required files and then executes node-gyp rebuild to create the build for the currently installed node js version. I have installed version 12 from nodejs.org and it breaks using that as shown above.

Thanks again for your interest and awaiting your courteous reply.
Dear jonnin,

Did you get a chance to help me out with compiling the library? I really appreciate your reply. Thank you.
Topic archived. No new replies allowed.