我正在尝试为Linux Mint 17上的Node构建一些示例附加组件。我一直遇到错误。我尝试将编译器更改为clang,也尝试使用[NAN] [1],但仍然出现错误

clang编译器产生的错误少于g++,但是我仍然得到

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info spawn python
gyp info spawn args [ '/home/someuser/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args       '/home/someuser/workspace/nonameproject/anothertest/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/someuser/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/someuser/.node-gyp/0.10.30/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/someuser/.node-gyp/0.10.30',
gyp info spawn args   '-Dmodule_root_dir=/home/someuser/workspace/nonameproject/anothertest',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/home/someuser/workspace/nonameproject/anothertest/build'
  CXX(target) Release/obj.target/addon/addon.o
clang: error: unknown argument: '-fno-tree-vrp'
make: *** [Release/obj.target/addon/addon.o] Error 1
make: Leaving directory `/home/someuser/workspace/nonameproject/anothertest/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/someuser/local/lib/node_modules/node-    gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.13.0-24-generic
gyp ERR! command "node" "/home/someuser/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/someuser/workspace/nonameproject/anothertest
gyp ERR! node -v v0.10.30
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

如果我将G++编译器与NAN一起使用,则会得到:

gyp info spawn args ['BUILDTYPE = Release','-C','build']
make:输入目录/home/someuser/workspace/nonameproject/anothertest/build' CXX(target) Release/obj.target/addon/addon.o In file included from ../addon.cc:11:0: .././sync.h:2:8: error: expected constructor, destructor, or type conversion before ‘-’ token * NAN - Native Abstractions for Node.js ^ ../addon.cc: In function ‘void InitAll(v8::Handle<v8::Object>)’: ../addon.cc:23:30: error: ‘CalculateSync’ was not declared in this scope NanNew<FunctionTemplate>(CalculateSync)->GetFunction()); ^ make: *** [Release/obj.target/addon/addon.o] Error 1 make: Leaving directory/home/someuser/workspace/nonameproject/anothertest/build'

如果我在不使用NAN的情况下使用G++,则会得到:
make: Entering directory `/home/someuser/workspace/nonameproject/mytest/build'
  CXX(target) Release/obj.target/binding/binding.o
../binding.cc:6:19: error: ‘FunctionCallbackInfo’ in namespace ‘v8’ does not name a type
 void Method(const v8::FunctionCallbackInfo<Value>& args) {
               ^
../binding.cc:6:23: error: ISO C++ forbids declaration of ‘parameter’ with no type [-    fpermissive]
 void Method(const v8::FunctionCallbackInfo<Value>& args) {
                   ^
../binding.cc:6:43: error: expected ‘,’ or ‘...’ before ‘<’ token
     void Method(const v8::FunctionCallbackInfo<Value>& args) {
                                       ^
../binding.cc: In function ‘void Method(int)’:
../binding.cc:8:28: error: no matching function for call to  ‘v8::HandleScope::HandleScope(v8::Isolate*&)’
   HandleScope scope(isolate);

等等 ....

有人可以解释一下问题是什么,以及如何修复环境以编译基本的Node插件示例?与C++ 11或V8中的某些问题有关吗?

最佳答案

在最后一种情况下,是因为您正在尝试使用比所链接的版本更高的v8版本代码(无论 bundle 在Node 0.10.30中)。

10-04 12:57