我正在尝试使用 node-ffi 在 JS 中加载 c++ dll。当 dll 没有任何外部依赖项时,它可以正常工作。但是当它有任何外部依赖时,它就会崩溃。
const ffi = require("@saleae/ffi");
const MyDll = new ffi.Library("./MyDll",{
"Sum":[ "int32", ["int32", "int32"] ],
"Subtraction":[ "int32", ["int32", "int32"] ],
"Execute":[ "int32",["string"] ]
});
let a = 10;
let b = 20;
let AddRes = MyDll.Sum(a, b);
let SubRes = MyDll.Subtraction(10, 20);
当“MyDll”有外部依赖时,它会崩溃并抛出下面提到的错误。
throw new Error('Dynamic Linking Error: ' + err)
^
Error: Dynamic Linking Error: Win32 error 126
at new DynamicLibrary (D:\Workspace\AddOnsChk1LoadDll\node_modules\@saleae\ffi\lib\dynamic_library.js:74:11)
at new Library (D:\Workspace\AddOnsChk1LoadDll\node_modules\@saleae\ffi\lib\library.js:45:12)
at Object.<anonymous> (D:\Workspace\AddOnsChk1LoadDll\app.js:5:15)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47