node Foreign Function Interface 中最基本的示例是atoi
通过从 node 自己的进程加载来调用:
var ffi = require('ffi');
var current = ffi.Library(null, {
'atoi': [ 'int', [ 'string' ] ]
});
console.log(typeof current.atoi('1234')); // 1234
但我得到这个错误:
throw new Error('Dynamic Symbol Retrieval Error: ' + this.error())
^
Error: Dynamic Symbol Retrieval Error: Win32 error 127
at DynamicLibrary.get (D:\web\node_modules\ffi\lib\dynamic_library.js:112:11)
at D:\web\node_modules\ffi\lib\library.js:50:19
at Array.forEach (native)
at Object.Library (D:\web\node_modules\ffi\lib\library.js:47:28)
at Object.<anonymous> (D:\web\native\winapi.js:5:19)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
显然它与 32/64 位不兼容无关,因为我正在访问自己的进程。那么究竟有什么问题呢?
- 平台:Windows 7x64
- 节点:v6.2.2
- 菲:2.2.0
- 参考:1.3.3