Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot find my dll
Forum Updated to NodeBB v4.3 + New Features

Cannot find my dll

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LovelyGrace
    wrote on last edited by
    #1

    I am trying to use my library from a console or widget application. I've tried this reference https://wiki.qt.io/How_to_link_to_a_dll but it didn't work. And it's producing error like:

    error: file not recognized: File format not recognized
    collect2.exe:-1: error: error: ld returned 1 exit status
    

    I am using qt 5.9 msvc 2015 and 2017. I also tried this:
    LIBS += -L"D:\Project\build-MyLibrary-Desktop_Qt_5_9_6_MSVC2015_64bit-Debug\debug" -lDLL
    but it produce error like:

    error: cannot find -lDLL
    collect2.exe:-1: error: error: ld returned 1 exit status
    

    What seemes to be wrong here? Can u help fix.

    jsulmJ 1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Is this library compiled using MSVC ? file format wrong indicates that it is not valid image.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      L 1 Reply Last reply
      0
      • dheerendraD dheerendra

        Is this library compiled using MSVC ? file format wrong indicates that it is not valid image.

        L Offline
        L Offline
        LovelyGrace
        wrote on last edited by
        #3

        @dheerendra said in Cannot find my dll:

        Is this library compiled using MSVC ? file format wrong indicates that it is not valid image.

        yes it is compiled using msvc. how can I fix it then?

        1 Reply Last reply
        0
        • L LovelyGrace

          I am trying to use my library from a console or widget application. I've tried this reference https://wiki.qt.io/How_to_link_to_a_dll but it didn't work. And it's producing error like:

          error: file not recognized: File format not recognized
          collect2.exe:-1: error: error: ld returned 1 exit status
          

          I am using qt 5.9 msvc 2015 and 2017. I also tried this:
          LIBS += -L"D:\Project\build-MyLibrary-Desktop_Qt_5_9_6_MSVC2015_64bit-Debug\debug" -lDLL
          but it produce error like:

          error: cannot find -lDLL
          collect2.exe:-1: error: error: ld returned 1 exit status
          

          What seemes to be wrong here? Can u help fix.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @LovelyGrace What is the file name of your DLL? DLL as file name for a lib is strange.
          Also, in the link you posted they do it like this:

          LIBS += "$$PWD/myLibrary/mylibrary.dll"
          

          Did you try?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          L 1 Reply Last reply
          0
          • jsulmJ jsulm

            @LovelyGrace What is the file name of your DLL? DLL as file name for a lib is strange.
            Also, in the link you posted they do it like this:

            LIBS += "$$PWD/myLibrary/mylibrary.dll"
            

            Did you try?

            L Offline
            L Offline
            LovelyGrace
            wrote on last edited by
            #5

            @jsulm said in Cannot find my dll:

            @LovelyGrace What is the file name of your DLL? DLL as file name for a lib is strange.
            Also, in the link you posted they do it like this:

            LIBS += "$$PWD/myLibrary/mylibrary.dll"
            

            Did you try?

            yes and I receive error like

            error: file not recognized: File format not recognized
            collect2.exe:-1: error: error: ld returned 1 exit status
            

            im not sure if it is has anything with the msvc version or kit version? is it? cause i only get the error if only choose kit version of msvc 2017 and 2015 for both library and console application.

            jsulmJ 1 Reply Last reply
            0
            • L LovelyGrace

              @jsulm said in Cannot find my dll:

              @LovelyGrace What is the file name of your DLL? DLL as file name for a lib is strange.
              Also, in the link you posted they do it like this:

              LIBS += "$$PWD/myLibrary/mylibrary.dll"
              

              Did you try?

              yes and I receive error like

              error: file not recognized: File format not recognized
              collect2.exe:-1: error: error: ld returned 1 exit status
              

              im not sure if it is has anything with the msvc version or kit version? is it? cause i only get the error if only choose kit version of msvc 2017 and 2015 for both library and console application.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @LovelyGrace said in Cannot find my dll:

              error: file not recognized: File format not recognized

              Then your DLL has different ABI (means is incompatible with your current compiler). Is your lib 32bit or 64bit. And what about your app (32bit/64bit)?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • L Offline
                L Offline
                LovelyGrace
                wrote on last edited by
                #7

                @jsulm said in Cannot find my dll:

                @LovelyGrace said in Cannot find my dll:

                error: file not recognized: File format not recognized

                Then your DLL has different ABI (means is incompatible with your current compiler). Is your lib 32bit or 64bit. And what about your app (32bit/64bit)?

                64 bit. How do I fix this then?

                Should both library and application has the same kit version? So that the application can use the library?

                jsulmJ 1 Reply Last reply
                0
                • L LovelyGrace

                  @jsulm said in Cannot find my dll:

                  @LovelyGrace said in Cannot find my dll:

                  error: file not recognized: File format not recognized

                  Then your DLL has different ABI (means is incompatible with your current compiler). Is your lib 32bit or 64bit. And what about your app (32bit/64bit)?

                  64 bit. How do I fix this then?

                  Should both library and application has the same kit version? So that the application can use the library?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @LovelyGrace You cannot mix 32bit and 64bit binaries. You need to build both as 32bit or 64bit. So, yes same Kit.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    LovelyGrace
                    wrote on last edited by
                    #9

                    From this statement:

                    copy .lib to project directory
                    in the directory with myProgram.pro, create the folder myLibrary. Enter this directory, and then copy the following files to it: mylibrary.dll, mylibrary.h and mylibrary_global.h
                    

                    which .dll should I get, from the debug or from the release? I am not sure to this though

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      LovelyGrace
                      wrote on last edited by
                      #10

                      Now I'm getting this error: LNK1107: invalid or corrupt file: cannot read at 0x330. Same kit version for library and application

                      jsulmJ 1 Reply Last reply
                      0
                      • L LovelyGrace

                        Now I'm getting this error: LNK1107: invalid or corrupt file: cannot read at 0x330. Same kit version for library and application

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @LovelyGrace I'm not a Windows expert, but as far as I know you need *.lib file for linking and *.dll for executing your app. So, in my opinion the description in the link you posted is wrong - you should add the lib file to your pro file, not dll. But I may be wrong here.
                        "which .dll should I get, from the debug or from the release?" - depending on whether you're building your app in debug or release mode (same story: don't mix debug and release binaries).

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved