鍍金池/ 問答/Python  C++  網(wǎng)絡安全/ 關于QT程序調用Fortran生成的Dll的問題,求解答?。?/span>

關于QT程序調用Fortran生成的Dll的問題,求解答!!

題目描述

QT+VS2017 無法調用Fortran生成的DLL

題目來源及自己的思路

自己學習中遇到的問題,當時以為是路徑的問題,但是我用絕對路徑也不行,把dll文件拷到exe目錄也不行。

相關代碼

// 請把代碼文本粘貼到下方(請勿用圖片代替代碼)
1、用LoadLibrary()

#include "Test00.h"
#include<Windows.h>
#include<qmessagebox.h>
typedef int(*FUNCTIONABZERO)(int input);

Test00::Test00(QWidget *parent)
    : QMainWindow(parent)
{
    ui.setupUi(this);
    loadDll = LoadLibrary(TEXT("C:\VisualStudioWorkspace\QtStudy\Test00\Test00\TestDll.dll"));
    if (loadDll == NULL)
    {
        QMessageBox::warning(this, QStringLiteral("警告!"), QStringLiteral("載入庫文件失敗!"), QMessageBox::Yes);
    }
}

void Test00::on_startBtn_clicked()
{
    FUNCTIONABZERO ABZERO = (FUNCTIONABZERO)GetProcAddress(loadDll,"ABZERO");
    if (ABZERO==NULL)
    {
        QMessageBox::warning(this, QStringLiteral("警告!"), QStringLiteral("函數(shù)不存在!"), QMessageBox::Yes);
    }
    else
    {
        int a = ui.arg1->text().trimmed().toInt();
        int result = ABZERO(a);
        ui.result->setText(QString::number(result));
    }
}

2、換用QLibrary

QLibrary myDLL("C:\VisualStudioWorkspace\QtStudy\Test00\Test00\TestDll.dll");
    if (myDLL.load())
    {
        QMessageBox::information(this,"OK","DLL is loaded! ");
    }
    else
    {
        QMessageBox::warning(this,"Warning","DLL load failure!");
    }

你期待的結果是什么?實際看到的錯誤信息又是什么?

希望大佬解惑!??!

回答
編輯回答
紓惘

已解決?。ortran生成dll時沒配置,默認生成32位的dll了。而我的QT程序是64位的,我又重新把dll生成64位的沒問題了

2017年8月5日 15:20