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 Code:
  1. QT += core gui
  2.  
  3. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  4.  
  5. CONFIG += c++14
  6.  
  7. LIBS += "C:\Users\lauer\Qt_Projects\build-firsttry32bit_gebiom-Desktop_x86_windows_msvc2019_pe_32bit-Debug\debug\GP_MUX_MODAWIFI.dll."
  8.  
  9.  
  10. SOURCES += \
  11. main.cpp \
  12. mainwindow.cpp
  13.  
  14. HEADERS += \
  15. mainwindow.h
  16.  
  17. FORMS += \
  18. mainwindow.ui
  19.  
  20. # Default rules for deployment.
  21. qnx: target.path = /tmp/$${TARGET}/bin
  22. else: unix:!android: target.path = /opt/$${TARGET}/bin
  23. !isEmpty(target.path): INSTALLS += target
To copy to clipboard, switch view to plain text mode 



main.cpp
Qt Code:
  1. #include "mainwindow.h"
  2.  
  3. #include <QApplication>
  4. #include <QLibrary>
  5. #include <QDebug>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. QApplication a(argc, argv);
  10.  
  11. 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
  12. QLibrary lib("C:/Users/lauer/Qt_Projects/build-firsttry32bit_gebiom-Desktop_x86_windows_msvc2019_pe_32bit-Debug/debug/GP_MUX_MODAWIFI.dll");
  13. lib.load();
  14. if (!lib.isLoaded()) {
  15. qDebug() << lib.errorString();
  16. }
  17.  
  18. if (lib.isLoaded()) {
  19. qDebug() << "success";
  20.  
  21. // Resolves symbol to
  22. // void the_function_name()
  23. typedef int (*FunctionPrototype)();
  24. auto function1 = (FunctionPrototype)lib.resolve("MUX_Version");
  25.  
  26.  
  27. // if null means the symbol was not loaded
  28. if (function1) function1();
  29. }
  30. }
  31.  
  32. MainWindow w;
  33. w.show();
  34. return a.exec();
  35. }
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