Results 1 to 2 of 2

Thread: LNK1107: Invalid or damaged file: reading at 0x2E0 not possible

  1. #1
    Join Date
    Apr 2021
    Posts
    4
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default LNK1107: Invalid or damaged file: reading at 0x2E0 not possible

    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

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: LNK1107: Invalid or damaged file: reading at 0x2E0 not possible

    Please do not double post. You already have one thread going on this issue. Make your additional comments there.

    Line 7 of your .pro file: You cannot link to a DLL, you can only link to static libraries or export libraries created for a DLL. (.lib files).
    Last edited by d_stranz; 2nd April 2021 at 17:53.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    tim5 (3rd April 2021)

Similar Threads

  1. Replies: 3
    Last Post: 19th January 2016, 10:57
  2. Replies: 5
    Last Post: 27th August 2015, 12:05
  3. HTTPS request returns damaged HTML body
    By ljuhrich in forum Qt Programming
    Replies: 6
    Last Post: 2nd June 2013, 09:37
  4. Replies: 3
    Last Post: 19th October 2011, 14:08
  5. Check for invalid file name in QFileDialog
    By darren in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 15:43

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.