node C++扩展引用动态链接库运行报错“无法找到指定的模块”

我用node_gyp将C++调用gdal库开发的代码编译成node的模块然后在node中调用其函数,但是我在运行时报错“无法找到指定的模块”不知道出了什么错误

相关代码

// binding.gyp文件
{
"variables":{

"dll_files":[
    "../gdal/bin/gdal203.dll"
  ] 

},
"targets": [

{
  "target_name": "addon",
  "sources": [
    "./C++_02/tile.cc"
  ],
  "include_dirs": [
    "./gdal/include"
  ],
  'libraries': [
     "../gdal/lib/gdal_i.lib",
  ],
}

]
}

//tile.cc文件
#include <node.h>
#include <v8.h>

#include "gdal_priv.h"
#include "ogrsf_frmts.h"

using namespace v8;

void tileload(const FunctionCallbackInfo<Value> &args)
{

Isolate *isolate = args.GetIsolate();

v8::String::Utf8Value s(args[0]);
std::string str(*s);  
const char* imagefile = str.c_str();
int x = args[1]->Int32Value();
int y = args[2]->Int32Value();
int l = args[3]->Int32Value();

}

//test.js
const addon = require('./build/Release/addon');

var imagefile = "/vsicurl/http://sasmac.oss-cn-beijing....f";
var x = 160;
var y = 83;
var l = 9;

addon.tileload(imagefile, x, y, l);

错误提示

[Running] node "e:cnodetest.js"
module.js:681
return process.dlopen(module, path._makeLong(filename));

             ^

Error: The specified module could not be found.

\?e:cnodebuildReleaseaddon.node

at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (e:\cnode\test.js:1:77)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)

[Done] exited with code=1 in 0.96 seconds
请大神帮忙看一下哪里有问题并给一些改正意见

阅读 4.6k
1 个回答

我在网上查了一下参阅文章https://www.cnblogs.com/lhwbl...
之所以找不到制定模块是因为缺少引用的.dll。文件我将gdal/bin文件夹中的所有.dll文件复制到build/Release文件夹中程序就正常运行了
clipboard.png

clipboard.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题