Tôi đang theo ví dụ nan, nhưng documention không hoạt động.Lỗi xây dựng Nan
binding.gyp tôi:
{
"targets":[
{
"target_name": "hello",
"sources": ["hello.cpp"],
"include_dirs": [
"<!(node -e \"require('nan')\")"
]
}
]
}
và hello.cpp tôi:
#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)
Đó là OK trong node-gyp configure
, nhưng khi node-gyp build
, nó báo cáo lỗi:
../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());
của tôi phiên bản nút là 5.7.0 và nút-gyp mới nhất là 3.3.0 nan mới nhất s mới nhất 2.2.0. Có thể một số mã tôi đã sử dụng trong ví dụ không được chấp nhận? Hoặc tôi nên làm gì để hoàn thành ví dụ xin chào? Cảm ơn
Tôi có cùng một vấn đề. – InsaneRabbit