Results 1 to 6 of 6

Thread: LNK1107 invalid or corrupt file; cannot read at 0x2EB | create & use a simple DLL fil

  1. #1

    Default LNK1107 invalid or corrupt file; cannot read at 0x2EB | create & use a simple DLL fil

    I was able to create a DLL file in the Debug mode, but due to this error I was unable to use it.

    Just a message that I wanted to display at the command line.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: LNK1107 invalid or corrupt file; cannot read at 0x2EB | create & use a simple DLL

    What would you like us to do about it? Apart from being able to guess you are use a Microsoft compiler on a Windows machine we have absolutely no information to work with.

  3. #3

    Default Re: LNK1107 invalid or corrupt file; cannot read at 0x2EB | create & use a simple DLL

    Here's the code, really nothing. Just trying to create DLL and use it

    File Name : createDLL.h
    #ifndef CREATEDLL_H
    #define CREATEDLL_H

    #include "createdll_global.h"

    class CREATEDLLSHARED_EXPORT CreateDLL
    {

    public:
    CreateDLL();
    void Message();
    };

    #endif // CREATEDLL_H

    File Name : createdll_global.h
    #ifndef CREATEDLL_GLOBAL_H
    #define CREATEDLL_GLOBAL_H

    #include <QtCore/qglobal.h>

    #if defined(CREATEDLL_LIBRARY)
    # define CREATEDLLSHARED_EXPORT Q_DECL_EXPORT
    #else
    # define CREATEDLLSHARED_EXPORT Q_DECL_IMPORT
    #endif

    #endif // CREATEDLL_GLOBAL_H

    File Name : createdll.cpp
    #include "createdll.h"
    #include "qDebug.h"


    CreateDLL::CreateDLL()
    {
    }

    void CreateDLL::Message()
    {
    qDebug() << "Hello from inside DLL";
    }

    Compiled it, just noticed now, exited with error code -1 ?
    M:\QtExamples\build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug exited with code -1

    DLL File Size = 46KB

    For using the DLL file I created a Console Application.
    I loaded the header files createdll.h & createll_global.h into the usingDLL project.

    Included the LIBS += "DLL File Path i.e. output from the code given"
    Compiled and got the error LNK1107 invalid or corrupt file: cannot read at 0x2D0

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: LNK1107 invalid or corrupt file; cannot read at 0x2EB | create & use a simple DLL

    Post the actual pro file you are using for your consumer program. If you have explicitly listed the DLL file in the LIBS variable then that would explain why the linker gets confused. The linker is not expecting the runtime library, it is expecting the link library created at the same time.

  5. #5

    Default Re: LNK1107 invalid or corrupt file; cannot read at 0x2EB | create & use a simple DLL

    Quote Originally Posted by ChrisW67 View Post
    Post the actual pro file you are using for your consumer program. If you have explicitly listed the DLL file in the LIBS variable then that would explain why the linker gets confused. The linker is not expecting the runtime library, it is expecting the link library created at the same time.
    Here's the pro file :

    #-------------------------------------------------
    #
    # Project created by QtCreator 2015-08-26T16:31:15
    #
    #-------------------------------------------------

    QT += core

    QT -= gui

    TARGET = usingDLL
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app'

    LIBS += "D:\Testing\build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug\debug\createDLL.dll"


    SOURCES += main.cpp

    HEADERS += \
    ../createDLL/createdll.h \
    ../createDLL/createdll_global.h

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: LNK1107 invalid or corrupt file; cannot read at 0x2EB | create & use a simple DLL

    Qt Code:
    1. LIBS += "D:\Testing\build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug\debug\createDLL.dll"
    To copy to clipboard, switch view to plain text mode 
    Quote Originally Posted by Me
    The linker is not expecting the runtime library, it is expecting the link library created at the same time as the DLL was compiled.
    The DLL file is a run-time library. In the same folder you will likely find a "createDLL.lib", which is the import or link library. It contains stubs and data about the run-time library that the linker can attach to the remainder of your program so it can access the run-time library at (you guessed it) run time. Your PRO file could look like:
    Qt Code:
    1. LIBS += "D:/Testing/build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug/debug/createDLL.lib"
    To copy to clipboard, switch view to plain text mode 
    although you could use the other syntax (something like):
    Qt Code:
    1. LIBS += -L"D:/Testing/build-createDLL-Desktop_Qt_5_5_0_MSVC2012_32bit-Debug/debug" -lcreateDLL
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 5
    Last Post: 11th February 2012, 22:17
  2. How to create a Simple DLL and use it in QT 4?
    By venkateshhegde in forum Newbie
    Replies: 6
    Last Post: 3rd March 2011, 14:10
  3. Replies: 5
    Last Post: 27th May 2009, 12:49
  4. QSocketNotifier: Invalid socket 12 and type 'Read', disabling...
    By kunalnandi in forum General Programming
    Replies: 1
    Last Post: 24th September 2008, 18:09
  5. How to read a simple xml file.
    By bod in forum Qt Programming
    Replies: 17
    Last Post: 27th June 2008, 09:13

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.