node-gyp build失败,不知道什么原因!!!

简单的丫头66 发布于 2015/02/27 19:34
阅读 12K+
收藏 0

写了个最简单的helloworld build失败,不知道是环境配置有问题还是什么原因啊!!!

hello.cc:

#include <node.h>
#include <v8.h>
using namespace v8;
Handle<Value> Method(const Arguments& args) {
    HandleScope scope;
    return scope.Close(String::New("Hello World!"));
}
void init(Handle<Object> target) {
    NODE_SET_METHOD(target, "sayHello", Method);
}
NODE_MODULE(hello, init);

binding.gyp:

{
  'targets': [
    {
      'target_name': 'hello',
      'sources': [
        'src/hello.cc'
      ],
      'dependencies': [
      ]
    }
  ]
}

运行node-gyp build失败:

@localhost :~/test/hello$ node-gyp build

gyp info it worked if it ends with ok
gyp info using node-gyp@1.0.2
gyp info using node@0.12.0 | linux | x64
child_process: customFds option is deprecated, use stdio instead.
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/home/yuying.wyy/test/hello/build'
  CXX(target) Release/obj.target/hello/src/hello.o
../src/hello.cc:15:1: error: stray ‘\343’ in program
../src/hello.cc:15:1: error: stray ‘\200’ in program
../src/hello.cc:15:1: error: stray ‘\200’ in program
../src/hello.cc:8:28: error: ‘Arguments’ does not name a type
../src/hello.cc:8:39: error: ISO C++ forbids declaration of ‘args’ with no type [-fpermissive]
/home/yuying.wyy/.node-gyp/0.12.0/deps/v8/include/v8.h: In function ‘v8::Handle<v8::Value> Method(const int&)’:
/home/yuying.wyy/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: error: ‘v8::HandleScope::HandleScope()’ is protected
../src/hello.cc:9:17: error: within this context
../src/hello.cc:11:18: error: ‘class v8::HandleScope’ has no member named ‘Close’
../src/hello.cc:11:24: error: ‘New’ is not a member of ‘v8::String’
../src/hello.cc: In function ‘void init(v8::Handle<v8::Object>)’:
../src/hello.cc:17:47: error: no matching function for call to ‘NODE_SET_METHOD(v8::Handle<v8::Object>&, const char [9], v8::Handle<v8::Value> (&)(const int&))’
../src/hello.cc:17:47: note: candidate is:
/home/yuying.wyy/.node-gyp/0.12.0/src/node.h:228:13: note: template<class TypeName> void node::NODE_SET_METHOD(const TypeName&, const char*, v8::FunctionCallback)
../src/hello.cc: In function ‘v8::Handle<v8::Value> Method(const int&)’:
../src/hello.cc:12:1: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [Release/obj.target/hello/src/hello.o] Error 1
make: Leaving directory `/home/yuying.wyy/test/hello/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.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Linux 3.2.0-60-generic
gyp ERR! command "node" "/usr/local/bin/node-gyp" "build"
gyp ERR! cwd /home/yuying.wyy/test/hello
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
加载中
0
lingyue1012
lingyue1012
解决了没?
0
wfifi
wfifi

挖个坟,可能源文件里的空白不是空格或tab。删除源文件中空白填上空格或tab试试。

参考http://www.jb51.net/article/39995.htm

返回顶部
顶部