![](/img/trans.png)
[英]JNI C++ DLL - 'UnsatisfiedLinkError: %1 is not a valid Win32 application'
[英]error: %1 is not a valid Win32 application while making node.js library in c++
我在Visual Studio中构建了节点,然后通过在Visual Studio项目中设置适当的路径来成功在.node扩展中编译此代码。
#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)
}
但是当我通过这段代码调用此模块时,
var addon = require('./nodeExt');
console.log(addon.hello());
我收到上述错误。 请提出您的建议。
在Visual Studio中构建并将扩展名更改为.node将不起作用。 您需要使用node-gyp为node.js配置和构建本机插件。 请参阅此处的指南:
https://nodejs.org/dist/latest-v6.x/docs/api/addons.html
提示:在运行node-gyp configure
,可以使用Visual Studio打开.sln文件(build / Release / binding.sln或build / Debug / binding.sln)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.