我在尝试使用nodejs-ffi模块加载C 32位DLL时遇到了麻烦。这是我的代码:
运行时,节点在Dynanic_library.js上抛出错误:74动态链接错误
var ffi = require('ffi');
var ref = require('ref');
var path = require('path');
import idatabase = require('./IDatabase');
import idataset = require('./Dataset');
var dllpath = path.join(__dirname, '../../StoneBaseDLL.dll');
var dbpath = path.join(__dirname, '../../../database/metadata/metadata.db');
export class Stonebase implements idatabase.IDatabase
{
dbHandler;
dbConnection;
constructor() {
this.dbHandler = ffi.Library(dllpath, {
'connect': ['void*', ['string']],
'Execute': ['void*', ['string', 'void*']],
'disconnect': ['void*', ['void*']],
'EndOfResultSet': ['bool', ['void*']],
'Next': ['void', ['void*']],
'getNumberOfFields': ['int', ['void*']],
'GetField_AsString': ['string', ['int', 'void*']],
'GetField_AsChar': ['string', ['int', 'void*']],
});
this.dbConnection = this.dbHandler.connect(dbpath);
}
execute(query: string) {
var data: Array<Array<string>>;
var columns: Array<string>;
data = [];
columns = [];
var i = 0;
var dset = this.dbHandler.Execute(query, this.dbConnection);
for (var j = 0; j < this.dbHandler.getNumberOfFields(dset); j++) {
columns[j] = "column" + j;
}
while (!this.dbHandler.EndOfResultSet(dset)) {
var line: Array<string>;
line = [];
for (var j = 0; j < this.dbHandler.getNumberOfFields(dset); j++) {
line[j] = (<string>this.dbHandler.GetField_AsChar(j, dset));
}
data[i] = line;
this.dbHandler.Next(dset);
i++;
}
return new idataset.Dataset(data, columns);
}
}
我使用的是打字稿,但我确信这与问题无关
谢谢你们的帮助!
答案 0 :(得分:0)
您是否检查过您的节点是32位?如果您的节点是64位,则切换到32并重试。