Coder Social home page Coder Social logo

mguardarini / nodejs-bind-cplusplus Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 18 KB

C++ and Node.js: An Unholy Combination….But Oh So Right

Python 16.20% Makefile 67.69% C++ 0.59% C 1.78% JavaScript 13.74%
node-ffi nodejs express bolierplate cplusplus binding api interface

nodejs-bind-cplusplus's Introduction

How to create js binding to c/c++ library using nodejs FFI

This is a simple example C/C++ math library binding to Node.JS using addon FFI(foreign feth interface) and web server with express.

If you have an existing library written in C/C++ and you want to use this in a Node.JS application or you want to create an interface binding for javascript, you using node-ffi is a Node.js addon for loading and calling dynamic libraries using pure JavaScript. It can be used to create bindings to native libraries without writing any C++ code.

To install dependency using NPM.

npm install

To Build the project

npm run build

To run the project

npm run start

Enjoy :)

nodejs-bind-cplusplus's People

Contributors

mguardarini avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

nodejs-bind-cplusplus's Issues

Cannot build project

Hello,

Could you please provide the node and python version that was used for this project?

I cannot build this project with the following error (npm install):

npm ERR! code 1
npm ERR! path C:\Projects\brainflow\javascript_package\nodejs-bind-cplusplus\node_modules\ffi
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Users\amalia\AppData\Local\Programs\Python\Python38\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:399:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Projects\\brainflow\\javascript_package\\nodejs-bind-cplusplus\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Projects\brainflow\javascript_package\nodejs-bind-cplusplus\node_modules\ffi
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

I have followed the instructions on https://github.com/nodejs/node-gyp but I guesss the project is much older so maybe an older version of python must be used?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.