初探nodejs的c++ addons问题汇总

参考官网手册一步步探摸索c++模块 和 v8,环境是ubuntu,碰到如下问题:

1、要写C++模块,必须先搭建一个环境,node-gyp命令是必须

    npm install -g node-gyp

发现发现通过网络代理进行下载,解决办法就是修改npm registry

     npm config set registry "http://registry.npmjs.org/"


2、按照官网手册执行如下命令

    node-gyp configure

    node-gyp build

执行后面命令时,出现错误:

make:进入目录'/home/llzeng/pro/nodejs/build'
  CXX(target) Release/obj.target/hello/hello.o
../hello.cc:6:28: 错误: ‘Argument’不是一个类型名
../hello.cc:6:38: 错误: ISO C++ 不允许声明无类型的‘args’ [-fpermissive]
../hello.cc: 在函数‘void init(v8::Handle<v8::Object>)’中:
../hello.cc:13:32: 错误: 从类型‘v8::Handle<v8::Value> (*)(const int&)’到类型‘v8::InvocationCallback {aka v8::Handle<v8::Value> (*)(const v8::Arguments&)}’的转换无效 [-fpermissive]
/home/llzeng/.node-gyp/0.10.26/deps/v8/include/v8.h:2255:34: 错误:   初始化‘static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::InvocationCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>)’的实参 1 [-fpermissive]
make: *** [Release/obj.target/hello/hello.o] 错误 1
make:离开目录“/home/llzeng/pro/nodejs/build”
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.2.0-59-generic
gyp ERR! command "node" "/usr/local/bin/node-gyp" "build"
gyp ERR! cwd /home/llzeng/pro/nodejs
gyp ERR! node -v v0.10.26
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok


你可能感兴趣的:(nodejs)