About the question that the QT program calls the Dll generated by Fortran, ask for the answer!

topic description

QT+VS2017 cannot call DLL generated by Fortran

sources of topics and their own ideas

the problem I encountered in my study was thought to be a path problem, but I couldn"t use an absolute path, and I couldn"t copy the dll file to the exe directory.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
1, use LoadLibrary ()

-sharpinclude "Test00.h"
-sharpinclude<Windows.h>
-sharpinclude<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("!"), QMessageBox::Yes);
    }
    else
    {
        int a = ui.arg1->text().trimmed().toInt();
        int result = ABZERO(a);
        ui.result->setText(QString::number(result));
    }
}

2. Switch to 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");
    }

what result do you expect? What is the error message actually seen?

I hope the boss will solve the problem!

May.11,2021

resolved! When Fortran generates dll, it is not configured, and 32-bit dll is generated by default. While my QT program is 64-bit, I have no problem generating 64-bit dll again

Menu