Podążam za przykładem nan, ale documention nie działa.Błąd kompilacji Nan
mój binding.gyp:
{
"targets":[
{
"target_name": "hello",
"sources": ["hello.cpp"],
"include_dirs": [
"<!(node -e \"require('nan')\")"
]
}
]
}
i mój 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)
Jest OK w node-gyp configure
, ale kiedy node-gyp build
, zgłasza błędy:
../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());
mój wersja węzła jest najnowszą wersją 5.7.0, a węzeł-gyp jest najnowszą wersją 3.3.0 nan i najnowszy 2.2.0. Czy jest możliwe, że niektóre kod użyty w przykładzie ma przestarzałe? Co powinienem zrobić, aby dokończyć przykład Hello? Dzięki
mam ten sam problem. – InsaneRabbit