Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs:How to call c++ DLL function through nodejs?

Tags:

I have a windows c++ DLL. It provides some functions like add(1,2). But I don't have the source code for this DLL, is it possible call functions in this DLL through nodejs, I mean, through web side and http. If it possible, what should I do?

like image 315
Zexi Li Avatar asked May 21 '15 03:05

Zexi Li


People also ask

How do you call a node function?

To call a function, you can either pass its name and arguments to User. callFunction() or call the function as if it was a method on the User.

Does Nodejs use C?

Yes, Node. js has a great portion of it written in C/C++ and a lot of its modules are actually implemented in C/C++. Just like any other javascript project out there, Node. js internally has a collection of dependencies that it uses to actually execute your code.


1 Answers

Did you check out the ffi nodejs library? https://github.com/node-ffi/node-ffi

var ffi = require('ffi');  var libm = ffi.Library('libm', {   'ceil': [ 'double', [ 'double' ] ] }); libm.ceil(1.5); // 2 
like image 188
Zsófi Ülkei Avatar answered Nov 28 '22 10:11

Zsófi Ülkei