nodejs的addon文档
https://nodejs.org/dist/latest-v8.x/docs/api/addons.html
V8 apireference
https://v8docs.nodesource.com/node-7.10/index.html
先上个最简单的代码 main.cc:
#include <node.h>
// using namespace v8;
namespace demo {
using v8::Local;
using v8::Object;
void init() {
printf("Hello node & V8 \n");
}
NODE_MODULE(test, init)
}
然后编译 node-gyp configure build 编译,再用js(如 hello.js)加载
require('./build/Release/addon-test');
执行js脚本,node hello.js,可以打印出
Hello node & V8