Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Qt 5.11.3 works fine, but Qt 5.12.1 throws LINKER errors

    Tools
    4
    25
    2150
    Loading More Posts
    • 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.
    • M
      m3g1dd last edited by m3g1dd

      On Windows 10, Qt 5.11.3 builds my application without any issue. However Qt 5.12.1, throws LINKER errors:

      main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl NetLibrary::registerNetLibraryQML(void)" (_imp?registerNetLibraryQML@NetLibrary@@YAXXZ) referenced in function main
      debug\application.exe : fatal error LNK1120: 1 unresolved externals

      my main.cpp is like:

      #include "../netlib/netlib.h"
      
      int main(int argc, char *argv[])
      {
          // ...
          NetLibrary::registerNetLibraryQML();
          // ...
      }
      

      My netlib.h contains:

      namespace NetLibrary {
      
      NETLIBSHARED_EXPORT void registerNetLibraryQML();
      
      }
      

      And my netlib.cpp contains:

      namespace NetLibrary {
      
      NETLIBSHARED_EXPORT void registerNetLibraryQML()
      {
          static bool registered = false;
          if (!registered) {
              qmlRegisterType<Netlib>("com.application.Application", 1, 0, "Netlib");
              registered = true;
          }
      }
      
      }
      

      I wonder why Qt 5.11.3 has no linker issue, but Qt 5.12.1 runs into errors.

      1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion last edited by

        So how to you link against the netlib library? Are you sure the netlib library is linked with the same compiler as Qt?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        M 2 Replies Last reply Reply Quote 3
        • M
          m3g1dd last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • M
            m3g1dd @Christian Ehrlicher last edited by

            @Christian-Ehrlicher

            The linking to net-library is done inside *.pro file:

            win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../netlib/release/ -lnetlib
            else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../netlib/debug/ -lnetlib
            else:unix: LIBS += -L$$OUT_PWD/../netlib/ -lnetlib
            
            INCLUDEPATH += $$PWD/../netlib
            DEPENDPATH += $$PWD/../netlib
            
            1 Reply Last reply Reply Quote 0
            • M
              m3g1dd @Christian Ehrlicher last edited by

              @Christian-Ehrlicher

              The compile which I'm using is MSVC2017_64bit :

              0_1552284678534_5763dfd5-db4b-4072-a483-eb3481b83aca-image.png

              0_1552284745737_5357e532-9eb7-4db9-beac-bcf8f1db78e0-image.png

              1 Reply Last reply Reply Quote 0
              • Christian Ehrlicher
                Christian Ehrlicher Lifetime Qt Champion last edited by

                MSVC needs the correct path instead -L and -l afaik
                https://doc.qt.io/qt-5/qmake-variable-reference.html#libs

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                M 1 Reply Last reply Reply Quote 2
                • M
                  m3g1dd @Christian Ehrlicher last edited by

                  @Christian-Ehrlicher

                  Thanks :) The strange point is that I have two more libraries which I'm linking against with the same approach without any issue. But only this net library is giving me troubles!

                  1 Reply Last reply Reply Quote 0
                  • Christian Ehrlicher
                    Christian Ehrlicher Lifetime Qt Champion last edited by

                    Maybe the function is not properly exported? Maybe take a look at the exported function declarations with Dependency Walker - make sure the export string (_imp?registerNetLibraryQML@NetLibrary@@YAXXZ) shown there looks exactly the same.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    M 2 Replies Last reply Reply Quote 2
                    • M
                      m3g1dd @Christian Ehrlicher last edited by

                      @Christian-Ehrlicher

                      Good idea :) I'm going to employ dependency walker tools

                      1 Reply Last reply Reply Quote 0
                      • M
                        m3g1dd @Christian Ehrlicher last edited by

                        @Christian-Ehrlicher

                        I double-checked my netlib DLL with dependency walker, I can see the export:

                        0_1552303570459_5fc43f6a-1a49-4307-b5b4-156b5e8b1a6c-image.png

                        Also, on my main.obj I can see the import:

                        0_1552303780368_7fcee3d7-1947-477a-8391-4ff3c54e5ef9-image.png

                        hskoglund 1 Reply Last reply Reply Quote 0
                        • Christian Ehrlicher
                          Christian Ehrlicher Lifetime Qt Champion last edited by

                          I've no idea - does the linker really links against the import lib? Are other functions from within the library are resolved?

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          M 1 Reply Last reply Reply Quote 0
                          • hskoglund
                            hskoglund @m3g1dd last edited by

                            @m3g1dd While checking the netlib DLL is a good thing for avoiding failures when launching your application.exe (when the .dll is loaded), here the error occurs not when running the app, but when linking it, So the .dll is immaterial, you could instead check the netlib.lib file, that's what the linker is reading.

                            Dependency Walker isn't well suited for reading .lib files, but there's a tool in MSVC2017 called dumpbin, easiest is to start it from a Developer Command Prompt for VS 2017. To get the complete information, use the /linkermember switch, say like this:

                            dumpbin /linkermember netlib.lib
                            

                            Then check in the list if that symbol is exported, it should be 2 of them, one __imp?registerNetLibraryQML@NetLibrary@@YAXXZ and one ?registerNetLibraryQML@NetLibrary@@YAXXZ

                            M 1 Reply Last reply Reply Quote 3
                            • M
                              m3g1dd @hskoglund last edited by m3g1dd

                              @hskoglund

                              Thanks! I run the command on Developer Command Prompt for VS 2017 and I get the results, I can see both ?registerNetLibraryQML@NetLibrary@@YAXXZ and __imp_?registerNetLibraryQML@NetLibrary@@YAXXZ expressions:

                              C:\Users\me\repos\build-application-Desktop_Qt_5_12_1_MSVC2017_64bit-Debug\netlib\debug>dumpbin /linkermember netlib.lib
                              Microsoft (R) COFF/PE Dumper Version 14.15.26730.0
                              Copyright (C) Microsoft Corporation.  All rights reserved.
                              
                              
                              Dump of file netlib.lib
                              
                              File Type: LIBRARY
                              
                              Archive member name at 8: /
                              FFFFFFFF time/date
                                       uid
                                       gid
                                     0 mode
                                   C3D size
                              correct header end
                              
                                  69 public symbols
                              
                                   190A __IMPORT_DESCRIPTOR_netlib
                                   1B30 __NULL_IMPORT_DESCRIPTOR
                                   1C66 netlib_NULL_THUNK_DATA
                                   2878 ?registerNetLibraryQML@NetLibrary@@YAXXZ
                                   2878 __imp_?registerNetLibraryQML@NetLibrary@@YAXXZ
                                   2E0C ?tr@Netlib@@SA?AVQString@@PEBD0H@Z
                                   2E0C __imp_?tr@Netlib@@SA?AVQString@@PEBD0H@Z
                                   2E8A ?trUtf8@Netlib@@SA?AVQString@@PEBD0H@Z
                                   2E8A __imp_?trUtf8@Netlib@@SA?AVQString@@PEBD0H@Z
                                   1DBE ??0Netlib@@QEAA@XZ
                                   1DBE __imp_??0Netlib@@QEAA@XZ
                                   1E2C ??1Netlib@@UEAA@XZ
                                   1E2C __imp_??1Netlib@@UEAA@XZ
                                   1F06 ?agentDiscover@Netlib@@QEAAXXZ
                                   1F06 __imp_?agentDiscover@Netlib@@QEAAXXZ
                                   1FFA ?agentSlice@Netlib@@QEAA_NAEBVQUrl@@AEBVQString@@V3@222@Z
                                   1FFA __imp_?agentSlice@Netlib@@QEAA_NAEBVQUrl@@AEBVQString@@V3@222@Z
                                   210E ?discoveryInProgress@Netlib@@QEBA_NXZ
                                   210E __imp_?discoveryInProgress@Netlib@@QEBA_NXZ
                                   28FC ?setDiscoveryInProgress@Netlib@@QEAAX_N@Z
                                   28FC __imp_?setDiscoveryInProgress@Netlib@@QEAAX_N@Z
                                   2C7E ?slicingInProgress@Netlib@@QEBA_NXZ
                                   2C7E __imp_?slicingInProgress@Netlib@@QEBA_NXZ
                                   2A82 ?setSlicingInProgress@Netlib@@QEAAX_N@Z
                                   2A82 __imp_?setSlicingInProgress@Netlib@@QEAAX_N@Z
                                   2530 ?layerID@Netlib@@QEBA?AVQString@@XZ
                                   2530 __imp_?layerID@Netlib@@QEBA?AVQString@@XZ
                                   2982 ?setLayerID@Netlib@@QEAAXVQString@@@Z
                                   2982 __imp_?setLayerID@Netlib@@QEAAXVQString@@@Z
                                   2B82 ?slicingDone@Netlib@@QEBA_NXZ
                                   2B82 __imp_?slicingDone@Netlib@@QEBA_NXZ
                                   2A04 ?setSlicingDone@Netlib@@QEAAX_N@Z
                                   2A04 __imp_?setSlicingDone@Netlib@@QEAAX_N@Z
                                   24BE ?init@Netlib@@AEAAXXZ
                                   24BE __imp_?init@Netlib@@AEAAXXZ
                                   22AA ?getOsName@Netlib@@AEAA?AVQString@@XZ
                                   22AA __imp_?getOsName@Netlib@@AEAA?AVQString@@XZ
                                   2090 ?discoveryFinished@Netlib@@AEAAXXZ
                                   2090 __imp_?discoveryFinished@Netlib@@AEAAXXZ
                                   2B06 ?slicerFinished@Netlib@@AEAAXXZ
                                   2B06 __imp_?slicerFinished@Netlib@@AEAAXXZ
                                   1F80 ?agentLogReady@Netlib@@AEAAXXZ
                                   1F80 __imp_?agentLogReady@Netlib@@AEAAXXZ
                                   2430 ?handleSlicingInProgressChanged@Netlib@@AEAAX_N@Z
                                   2430 __imp_?handleSlicingInProgressChanged@Netlib@@AEAAX_N@Z
                                   232C ?getSlicerProgress@Netlib@@AEAAXXZ
                                   232C __imp_?getSlicerProgress@Netlib@@AEAAXXZ
                                   23AA ?getSlicerProgressFinished@Netlib@@AEAAXXZ
                                   23AA __imp_?getSlicerProgressFinished@Netlib@@AEAAXXZ
                                   1E9A __imp_??_7Netlib@@6B@
                                   2636 ?metaObject@Netlib@@UEBAPEBUQMetaObject@@XZ
                                   2636 __imp_?metaObject@Netlib@@UEBAPEBUQMetaObject@@XZ
                                   2752 ?qt_metacast@Netlib@@UEAAPEAXPEBD@Z
                                   2752 __imp_?qt_metacast@Netlib@@UEAAPEAXPEBD@Z
                                   26BE ?qt_metacall@Netlib@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z
                                   26BE __imp_?qt_metacall@Netlib@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z
                                   27D2 ?qt_static_metacall@Netlib@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z
                                   27D2 __imp_?qt_static_metacall@Netlib@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z
                                   2190 ?discoveryInProgressChanged@Netlib@@QEAAX_N@Z
                                   2190 __imp_?discoveryInProgressChanged@Netlib@@QEAAX_N@Z
                                   221A ?discoveryResultChanged@Netlib@@QEAAXVQJsonArray@@@Z
                                   221A __imp_?discoveryResultChanged@Netlib@@QEAAXVQJsonArray@@@Z
                                   2CFE ?slicingInProgressChanged@Netlib@@QEAAX_N@Z
                                   2CFE __imp_?slicingInProgressChanged@Netlib@@QEAAX_N@Z
                                   25B0 ?layerIDChanged@Netlib@@QEAAXVQString@@@Z
                                   25B0 __imp_?layerIDChanged@Netlib@@QEAAXVQString@@@Z
                                   2BFC ?slicingDoneChanged@Netlib@@QEAAX_N@Z
                                   2BFC __imp_?slicingDoneChanged@Netlib@@QEAAX_N@Z
                                   2D86 __imp_?staticMetaObject@Netlib@@2UQMetaObject@@B
                              
                              Archive member name at C82: /
                              FFFFFFFF time/date
                                       uid
                                       gid
                                     0 mode
                                   C4B size
                              correct header end
                              
                                  37 offsets
                              
                                      1     190A
                                      2     1B30
                                      3     1C66
                                      4     2878
                                      5     2E0C
                                      6     2E8A
                                      7     1DBE
                                      8     1E2C
                                      9     1F06
                                      A     1FFA
                                      B     210E
                                      C     28FC
                                      D     2C7E
                                      E     2A82
                                      F     2530
                                     10     2982
                                     11     2B82
                                     12     2A04
                                     13     24BE
                                     14     22AA
                                     15     2090
                                     16     2B06
                                     17     1F80
                                     18     2430
                                     19     232C
                                     1A     23AA
                                     1B     1E9A
                                     1C     2636
                                     1D     2752
                                     1E     26BE
                                     1F     27D2
                                     20     2190
                                     21     221A
                                     22     2CFE
                                     23     25B0
                                     24     2BFC
                                     25     2D86
                              
                                  69 public symbols
                              
                                      7 ??0Netlib@@QEAA@XZ
                                      8 ??1Netlib@@UEAA@XZ
                                      9 ?agentDiscover@Netlib@@QEAAXXZ
                                     17 ?agentLogReady@Netlib@@AEAAXXZ
                                      A ?agentSlice@Netlib@@QEAA_NAEBVQUrl@@AEBVQString@@V3@222@Z
                                     15 ?discoveryFinished@Netlib@@AEAAXXZ
                                      B ?discoveryInProgress@Netlib@@QEBA_NXZ
                                     20 ?discoveryInProgressChanged@Netlib@@QEAAX_N@Z
                                     21 ?discoveryResultChanged@Netlib@@QEAAXVQJsonArray@@@Z
                                     14 ?getOsName@Netlib@@AEAA?AVQString@@XZ
                                     19 ?getSlicerProgress@Netlib@@AEAAXXZ
                                     1A ?getSlicerProgressFinished@Netlib@@AEAAXXZ
                                     18 ?handleSlicingInProgressChanged@Netlib@@AEAAX_N@Z
                                     13 ?init@Netlib@@AEAAXXZ
                                      F ?layerID@Netlib@@QEBA?AVQString@@XZ
                                     23 ?layerIDChanged@Netlib@@QEAAXVQString@@@Z
                                     1C ?metaObject@Netlib@@UEBAPEBUQMetaObject@@XZ
                                     1E ?qt_metacall@Netlib@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z
                                     1D ?qt_metacast@Netlib@@UEAAPEAXPEBD@Z
                                     1F ?qt_static_metacall@Netlib@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z
                                      4 ?registerNetLibraryQML@NetLibrary@@YAXXZ
                                      C ?setDiscoveryInProgress@Netlib@@QEAAX_N@Z
                                     10 ?setLayerID@Netlib@@QEAAXVQString@@@Z
                                     12 ?setSlicingDone@Netlib@@QEAAX_N@Z
                                      E ?setSlicingInProgress@Netlib@@QEAAX_N@Z
                                     16 ?slicerFinished@Netlib@@AEAAXXZ
                                     11 ?slicingDone@Netlib@@QEBA_NXZ
                                     24 ?slicingDoneChanged@Netlib@@QEAAX_N@Z
                                      D ?slicingInProgress@Netlib@@QEBA_NXZ
                                     22 ?slicingInProgressChanged@Netlib@@QEAAX_N@Z
                                      5 ?tr@Netlib@@SA?AVQString@@PEBD0H@Z
                                      6 ?trUtf8@Netlib@@SA?AVQString@@PEBD0H@Z
                                      1 __IMPORT_DESCRIPTOR_netlib
                                      2 __NULL_IMPORT_DESCRIPTOR
                                      7 __imp_??0Netlib@@QEAA@XZ
                                      8 __imp_??1Netlib@@UEAA@XZ
                                     1B __imp_??_7Netlib@@6B@
                                      9 __imp_?agentDiscover@Netlib@@QEAAXXZ
                                     17 __imp_?agentLogReady@Netlib@@AEAAXXZ
                                      A __imp_?agentSlice@Netlib@@QEAA_NAEBVQUrl@@AEBVQString@@V3@222@Z
                                     15 __imp_?discoveryFinished@Netlib@@AEAAXXZ
                                      B __imp_?discoveryInProgress@Netlib@@QEBA_NXZ
                                     20 __imp_?discoveryInProgressChanged@Netlib@@QEAAX_N@Z
                                     21 __imp_?discoveryResultChanged@Netlib@@QEAAXVQJsonArray@@@Z
                                     14 __imp_?getOsName@Netlib@@AEAA?AVQString@@XZ
                                     19 __imp_?getSlicerProgress@Netlib@@AEAAXXZ
                                     1A __imp_?getSlicerProgressFinished@Netlib@@AEAAXXZ
                                     18 __imp_?handleSlicingInProgressChanged@Netlib@@AEAAX_N@Z
                                     13 __imp_?init@Netlib@@AEAAXXZ
                                      F __imp_?layerID@Netlib@@QEBA?AVQString@@XZ
                                     23 __imp_?layerIDChanged@Netlib@@QEAAXVQString@@@Z
                                     1C __imp_?metaObject@Netlib@@UEBAPEBUQMetaObject@@XZ
                                     1E __imp_?qt_metacall@Netlib@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z
                                     1D __imp_?qt_metacast@Netlib@@UEAAPEAXPEBD@Z
                                     1F __imp_?qt_static_metacall@Netlib@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z
                                      4 __imp_?registerNetLibraryQML@NetLibrary@@YAXXZ
                                      C __imp_?setDiscoveryInProgress@Netlib@@QEAAX_N@Z
                                     10 __imp_?setLayerID@Netlib@@QEAAXVQString@@@Z
                                     12 __imp_?setSlicingDone@Netlib@@QEAAX_N@Z
                                      E __imp_?setSlicingInProgress@Netlib@@QEAAX_N@Z
                                     16 __imp_?slicerFinished@Netlib@@AEAAXXZ
                                     11 __imp_?slicingDone@Netlib@@QEBA_NXZ
                                     24 __imp_?slicingDoneChanged@Netlib@@QEAAX_N@Z
                                      D __imp_?slicingInProgress@Netlib@@QEBA_NXZ
                                     22 __imp_?slicingInProgressChanged@Netlib@@QEAAX_N@Z
                                     25 __imp_?staticMetaObject@Netlib@@2UQMetaObject@@B
                                      5 __imp_?tr@Netlib@@SA?AVQString@@PEBD0H@Z
                                      6 __imp_?trUtf8@Netlib@@SA?AVQString@@PEBD0H@Z
                                      3 netlib_NULL_THUNK_DATA
                              
                                Summary
                              
                                        C0 .debug$S
                                        14 .idata$2
                                        14 .idata$3
                                         8 .idata$4
                                         8 .idata$5
                                         C .idata$6
                              
                              1 Reply Last reply Reply Quote 0
                              • M
                                m3g1dd @Christian Ehrlicher last edited by

                                @Christian-Ehrlicher

                                Thanks! Yes, other functions of netlib are linked fine. I will update if I figure out the cause :)

                                1 Reply Last reply Reply Quote 0
                                • hskoglund
                                  hskoglund last edited by

                                  Hi, just to check, what version of MSVC did you use for Qt 5.11.3 (when the linking worked), was it MSVC 2017 32-bit or MSVC 2017 64-bit?

                                  M 1 Reply Last reply Reply Quote 0
                                  • M
                                    m3g1dd @hskoglund last edited by

                                    @hskoglund

                                    Hi! Thanks for follow up :)

                                    For Qt 5.11.3 I'm using MSVC2017_64bit which works fine. My build directories are:

                                    build-application-Desktop_Qt_5_11_3_MSVC2017_64bit-Debug
                                    build-application-Desktop_Qt_5_11_3_MSVC2017_64bit-Release
                                    build-application-Desktop_Qt_5_12_1_MSVC2017_64bit-Debug
                                    
                                    1 Reply Last reply Reply Quote 0
                                    • M
                                      m3g1dd last edited by m3g1dd

                                      New observation: I installed Qt5.12.0 and my application compiles/links/runs just fine. I'm going to re-install Qt5.12.1 ... I have a feeling maybe re-installing it will resolve linker errors ... lets see ...

                                      1 Reply Last reply Reply Quote 0
                                      • M
                                        m3g1dd last edited by

                                        I reinstalled Qt 5.12.1 but it still throws the above-mentioned linker error. So basically, my observation is:

                                        1. On Windows, Qt 5.11.3 and 5.12.0 work fine
                                        2. On Windows, Qt 5.12.1 throws linker error
                                        3. On Linux openSUSE Leap 15, Qt 5.12.1 works fine
                                        1 Reply Last reply Reply Quote 0
                                        • hskoglund
                                          hskoglund last edited by

                                          Hmm, just to check again: release builds and debug builds on 5.12.0 MSVC 2017 links fine and dandy, but the same linker throws a tantrum both for release and debug builds on 5.12.1 MSVC 2017.

                                          Also, could do you a similar dumpbin on a 5.12.0 debug built netlib.lib as you did above for a 5.12.1 debug build?

                                          M 2 Replies Last reply Reply Quote 2
                                          • M
                                            m3g1dd @hskoglund last edited by

                                            @hskoglund

                                            Let me double-check everything again ... I'll give an update ...

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post