IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    使用node-gyp 报错 ,不知道怎么解决,请予以指导一下

    muyoucun557发表于 2017-05-23 11:40:33
    love 0

    环境:Ubuntu虚拟机 场景描述:按照nodejs文档中的C++插件部分运行node-gyp报错。代码如下: hello.cc

    	#include <node.h>
    		namespace demo {
    		using v8::FunctionCallbackInfo;
    		using v8::Isolate;
    		using v8::Local;
    		using v8::Object;
    		using v8::String;
    		using v8::Value;
    		void Method(const FunctionCallbackInfo<Value>& args) {
      			Isolate* isolate = args.GetIsolate();
      			args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
    		}
    		void init(Local<Object> exports) {
      			NODE_SET_METHOD(exports, "hello", Method);
    		}
    		NODE_MODULE(addon, init)
    } 
    

    hello.js

    	const addon = require('./build/Release/addon');
    	console.log(addon.hello());
    

    编译好之后,运行hello.js报如下错误



沪ICP备19023445号-2号
友情链接