Using nbind to compile C++ into asm.js and Node.js addons on all platforms

Started by
-1 comments, last by jjrv 7 years, 10 months ago

I've just released nbind ( https://github.com/charto/nbind#readme ) which builds C++ projects into asm.js for web apps and native binary addons for Node.js or Electron. It works with GCC, Clang, Visual Studio and Emscripten on Linux, Windows and OS X.

nbind comes with headers using C++ templates that allow adding this kind of declaration at the end of a C++ source file:


#include "nbind/nbind.h"

NBIND_CLASS(MyClass) {
  method(myMethod);
  method(anotherMethod);
}

It auto-detects types of method parameters and return values using template magic (including things like std::vector<std::string>), and generates necessary bindings for calling the code from JavaScript or TypeScript. Native binaries and asm.js modules are easy to bundle into npm packages. Additionally asm.js modules can be included in web apps with script tags. The actual C++ code doesn't need any other changes.

nbind configures node-gyp which can generate makefiles and Visual Studio solutions targeting both native code (using above mentioned C++ compilers) and asm.js (using Emscripten). The user guide in the readme should explain everything in more detail.

This topic is closed to new replies.

Advertisement