I have a piece of C code which returns a string output. The same api is packaged in the form of a .so file.
How can i use the .so file directly in my nodejs code. Do i need to add something in my C code or there is a standard mechanism in node for the same..?
Thanks
You can't. What you can do is to write a C executable which uses the so library and returns an output. You can call this in your js file using the exec function.
exec('/<path_to_executable>/executable',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With