2016-02-25 11 views
8

मैं नैन उदाहरण का पालन कर रहा हूं, लेकिन documention काम नहीं करता है।नैन बिल्ड त्रुटि

मेरी binding.gyp:

{ 
    "targets":[ 
    { 
     "target_name": "hello", 
     "sources": ["hello.cpp"], 
     "include_dirs": [ 
     "<!(node -e \"require('nan')\")" 
     ] 
    } 
    ] 
} 

और मेरे hello.cpp:

#include <nan.h> 

using namespace v8; 

NAN_METHOD(Method) { 
    NanScope(); 
    NanReturenValue(String::New("world")); 
} 

void Init(Handle<Object> exports) { 
    exports->Set(NanSymbol("hello"), FunctionTemplate::New(Method)->GetFunction()); 
} 

NODE_MODULE(hello, Init) 

यह node-gyp configure में ठीक है, लेकिन जब node-gyp build, उसमें त्रुटियां रिपोर्ट:

../hello.cpp:10:9: error: use of undeclared identifier 'NanScope' 
    NanScope(); 
    ^
../hello.cpp:11:33: error: no member named 'New' in 'v8::String' 
    NanReturenValue(String::New("world")); 
        ~~~~~~~~^ 
../hello.cpp:15:18: error: use of undeclared identifier 'NanSymbol' 
exports->Set(NanSymbol("hello"), FunctionTemplate::New(Method)->GetFunction()); 
      ^
../hello.cpp:15:60: error: cannot initialize a parameter of type 'v8::Isolate *' with an lvalue of type 'Nan::NAN_METHOD_RETURN_TYPE (Nan::NAN_METHOD_ARGS_TYPE)' 
exports->Set(NanSymbol("hello"), FunctionTemplate::New(Method)->GetFunction()); 

मेरी नोड संस्करण नवीनतम 5.7.0 है और नोड-जीईपी नवीनतम 3.3.0 नैन i है नवीनतम 2.2.0। क्या यह संभव है कि उदाहरण में उपयोग किए गए कुछ कोड को हटा दिया गया है? या हैलो उदाहरण को पूरा करने के लिए मुझे क्या करना चाहिए? धन्यवाद

+0

मैं एक ही मुद्दा है। – InsaneRabbit

उत्तर

1

मैं बस उसी मुद्दे पर भाग गया, जो मैं बता सकता हूं कि उदाहरण दिनांकित है। मेरे लिए काम किया है:

#include <nan.h> 

void Method(const Nan::FunctionCallbackInfo<v8::Value>& info) { 
    info.GetReturnValue().Set(Nan::New("world").ToLocalChecked()); 
} 

void Init(v8::Local<v8::Object> exports) { 
    exports->Set(Nan::New("hello").ToLocalChecked(), 
       Nan::New<v8::FunctionTemplate>(Method)->GetFunction()); 
} 

NODE_MODULE(hello, Init) 

मूल रूप से करने के बजाय से कोड का उपयोग कर - मैं यहाँ से कोड चलाने की कोशिश की https://github.com/nodejs/node-addon-examples/tree/master/1_hello_world - https://github.com/nodejs/node-addon-examples/tree/master/1_hello_world/nan

संबंधित मुद्दे