Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81113

Linking against static Qt fails with LNK error due to missing dependencies

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.14.0
    • Build System
    • None
    • Windows 10/VCPKG
    • All

    Description

      What I am trying to achieve:
      Building ParaView with a statically build version of Qt using vcpkg.

      I was successful with 5.12.5 by adding a lot of dependencies and plugins by hand and decided to try out 5.14 because it should take care of adding the dependencies manually by parsing the PRL files.

      As it turns the build of ParaView failed due to Qt linking both DEBUG and RELEASE libraries to the DEBUG build of ParaView (e.g. Qt5Widgetsd.lib and Qt5Widgets.lib). I fixed it (a) but currently still get linker errors due to not linking iphlpapi.lib (see end):

      So what did I do to solve (a)

      • Add the parsing of the debug PRL if it exists
      • populate the DEBUG plugin properties if the debug plugin exists
      • Escape the generator expression (and removed the IsDebugAndRelease case since it is just plain stupid..... If you do not want to differentiate between configurations do it in another way)
        e.g. in the resulting Qt5Widgets.cmake (requires three \\\ in the source cmake.in)
                if(${Configuration} STREQUAL "DEBUG")
                    set(_genex_condition "\$<CONFIG:Debug>")
                else()
                    set(_genex_condition "\$<NOT:\$<CONFIG:Debug>>")
                endif()
        
      • add each library as a single element to INTERFACE_LINK_LIBRARIES since genxp and lists don't mix well in CMake by my experience. (Also adding each linked library as a single element with genexp is the way CMake does it with its generated targets)
        e.g.
            if(_static_deps)
                foreach(_static_dep ${_static_deps})
                    set(_static_dep_genex "\$<${_genex_condition}:${_static_dep}>")
                    set_property(TARGET Qt5::Widgets APPEND PROPERTY INTERFACE_LINK_LIBRARIES
                                 ${_static_dep_genex}
                    )
                endforeach()
            endif()
        

      Suggestion:

      • Move your damn parsing and populate macros to some other more general location then duplicating them all over the place in every module..... makes it really hard to modify a single line for testing because it has to be done in all the generated files....
      • I can only hope that Qt6 exports CMake auto generated targets which hopefully work.
      Qt5Networkd.lib(qnetconmonitor_win.obj) : error LNK2019: unresolved external symbol __imp_ConvertInterfaceIndexToLuid referenced in function "public: bool __cdecl QNetworkConnectionEvents::setTarget(class QNetworkInterface const &)" (?setTarget@QNetworkConnectionEvents@@QEAA_NAEBVQNetworkInterface@@@Z)
      Qt5Networkd.lib(qnetworkinterface_win.obj) : error LNK2001: unresolved external symbol __imp_ConvertInterfaceIndexToLuid
      Qt5Networkd.lib(qnetconmonitor_win.obj) : error LNK2019: unresolved external symbol __imp_ConvertInterfaceLuidToGuid referenced in function "public: bool __cdecl QNetworkConnectionEvents::setTarget(class QNetworkInterface const &)" (?setTarget@QNetworkConnectionEvents@@QEAA_NAEBVQNetworkInterface@@@Z)
      Qt5Networkd.lib(qnetworkinterface_win.obj) : error LNK2019: unresolved external symbol __imp_GetNetworkParams referenced in function "public: static class QString __cdecl QHostInfo::localDomainName(void)" (?localDomainName@QHostInfo@@SA?AVQString@@XZ)
      Qt5Networkd.lib(qnetworkinterface_win.obj) : error LNK2019: unresolved external symbol __imp_GetAdaptersAddresses referenced in function "class QList<class QNetworkInterfacePrivate *> __cdecl interfaceListing(void)" (?interfaceListing@@YA?AV?$QList@PEAVQNetworkInterfacePrivate@@@@XZ)
      Qt5Networkd.lib(qnetworkinterface_win.obj) : error LNK2019: unresolved external symbol __imp_ConvertInterfaceNameToLuidW referenced in function "public: static unsigned int __cdecl QNetworkInterfaceManager::interfaceIndexFromName(class QString const &)" (?interfaceIndexFromName@QNetworkInterfaceManager@@SAIAEBVQString@@@Z)
      Qt5Networkd.lib(qnetworkinterface_win.obj) : error LNK2019: unresolved external symbol __imp_ConvertInterfaceLuidToNameW referenced in function "public: static class QString __cdecl QNetworkInterfaceManager::interfaceNameFromIndex(unsigned int)" (?interfaceNameFromIndex@QNetworkInterfaceManager@@SA?AVQString@@I@Z)
      Qt5Networkd.lib(qnetworkinterface_win.obj) : error LNK2019: unresolved external symbol __imp_ConvertInterfaceLuidToIndex referenced in function "public: static unsigned int __cdecl QNetworkInterfaceManager::interfaceIndexFromName(class QString const &)" (?interfaceIndexFromName@QNetworkInterfaceManager@@SAIAEBVQString@@@Z)
      

      Note: Qt5Network seems to be pulled in by qtuiotouchplugin. The PRL contains the required dependencies. So it is probably due to the fact that you add those libraries to INTERFACE_LINK_OPTIONS instead of INTERFACE_LINK_LIBRARIES for some strange reason and since ParaView is at "cmake_minimum_required(VERSION 3.10 FATAL_ERROR)" it will simply ignore that setting even when I am using a higher CMake version

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtbuildsystem Qt Build System Team
            neumann-a Alexander Neumann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes