Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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"


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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!