我在尝试使用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);
    }

}


我正在使用Typescript,但是我很确定这与问题无关

谢谢大家的帮助!

最佳答案

您是否检查过您的节点是否为32位?如果您的节点是64位,则切换到32位,然后重试。

关于node.js - node-ffi模块无法加载32位C dll-动态链接错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26108718/

10-15 14:50