I was create a web API with nodeJS and now I want to call C++ dll functions in it. The functions take a long while to executing (Complex image processing functions with openCV) and I want calling them in nodeJS async, many requests most process with this DLLs. how can I do that?
Asked
Active
Viewed 5,382 times
1 Answers
4
You can use C++ Addons for this, a tutorial is in https://nodeaddons.com/calling-native-c-dlls-from-a-node-js-web-app/. It uses the node foreign function interface ( node-ffi ) to call code from .dll directly ( https://github.com/node-ffi/node-ffi/wiki/Node-FFI-Tutorial ). node-ffi basically provides wrapper functions for the functions in the dynamic library.
For the async requirement you can use Async Library Calls ability of node-ffi ( https://github.com/node-ffi/node-ffi/wiki/Node-FFI-Tutorial, chapter Async Library Calls ) or alternatively multiple processes like in How to create threads in nodejs

ralf htp
- 9,149
- 4
- 22
- 34