/bind_cpp_js

testing how to bind C++ code from JavaScript code in browser using nbind.

Primary LanguageC++MIT LicenseMIT

bind_cpp_js

Testing how to bind C++ code from JavaScript code in browser using nbind.

Depends on nbind to easily define addon's API and on autogypi to handle compiler & node-gyp options to compile native code. For a browser environment emscripten should be installed.

Setup dependencies

  brew install emscriptem

LLVM_ROOT must be updated manually when installing using Homebrew. You should edit ~/.emscripten and change

LLVM_ROOT = os.path.expanduser(os.getenv('LLVM') or '/usr/bin') # directory

to

LLVM_ROOT = os.path.expanduser(os.getenv('LLVM') or '/usr/local/Cellar/llvm/3.2/bin') # directory

Initialize (on project creation only)

Initialize it like this:

npm run -- autogypi --init-gyp -p nbind -s greeter.cxx

Your package should also include binding.gyp and autogypi.json files.

Build

for node environment (server)

node-gyp configure build

for browser environment

node-gyp configure build --asmjs=1