Hello,
I only have a .DLL file from an external source. No .lib or .h. This is why I am using LoadLibrary (QLibrary)- I was reading that if I only have the .dll I have to do it like that.
I know the functions but dont know how to implement the Dll correctly.
This ist what I tried:
.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++14
LIBS += "C:\Users\lauer\Qt_Projects\build-firsttry32bit_gebiom-Desktop_x86_windows_msvc2019_pe_32bit-Debug\debug\GP_MUX_MODAWIFI.dll."
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++14
LIBS += "C:\Users\lauer\Qt_Projects\build-firsttry32bit_gebiom-Desktop_x86_windows_msvc2019_pe_32bit-Debug\debug\GP_MUX_MODAWIFI.dll."
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
To copy to clipboard, switch view to plain text mode
main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QLibrary>
#include <QDebug>
int main(int argc, char *argv[])
{
if (QLibrary::isLibrary("C:/Users/lauer/Qt_Projects/build-firsttry32bit_gebiom-Desktop_x86_windows_msvc2019_pe_32bit-Debug/debug/GP_MUX_MODAWIFI.dll")) { // GP_MUX_MODAWIFI.dll QLibrary lib
("C:/Users/lauer/Qt_Projects/build-firsttry32bit_gebiom-Desktop_x86_windows_msvc2019_pe_32bit-Debug/debug/GP_MUX_MODAWIFI.dll");
lib.load();
if (!lib.isLoaded()) {
qDebug() << lib.errorString();
}
if (lib.isLoaded()) {
qDebug() << "success";
// Resolves symbol to
// void the_function_name()
typedef int (*FunctionPrototype)();
auto function1 = (FunctionPrototype)lib.resolve("MUX_Version");
// if null means the symbol was not loaded
if (function1) function1();
}
}
MainWindow w;
w.show();
return a.exec();
}
#include "mainwindow.h"
#include <QApplication>
#include <QLibrary>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if (QLibrary::isLibrary("C:/Users/lauer/Qt_Projects/build-firsttry32bit_gebiom-Desktop_x86_windows_msvc2019_pe_32bit-Debug/debug/GP_MUX_MODAWIFI.dll")) { // GP_MUX_MODAWIFI.dll
QLibrary lib("C:/Users/lauer/Qt_Projects/build-firsttry32bit_gebiom-Desktop_x86_windows_msvc2019_pe_32bit-Debug/debug/GP_MUX_MODAWIFI.dll");
lib.load();
if (!lib.isLoaded()) {
qDebug() << lib.errorString();
}
if (lib.isLoaded()) {
qDebug() << "success";
// Resolves symbol to
// void the_function_name()
typedef int (*FunctionPrototype)();
auto function1 = (FunctionPrototype)lib.resolve("MUX_Version");
// if null means the symbol was not loaded
if (function1) function1();
}
}
MainWindow w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
What can I do?
What am I doing wrong?
I already looked into several forum entries but did not find the working answer.
Thanks in advance
Tim
Bookmarks