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

qt_add_qml_module with NO_PLUGIN can fail to load when using as-needed linking

    XMLWordPrintable

Details

    Description

      Consider the following CMake code:

       

      set(CMAKE_CXX_FLAGS "-Wl,-as-needed")
      
      add_executable(foo main.cpp)
      
      add_library(bla SHARED)
      qt_add_qml_module(bla URI "org.kde.bla" NO_PLUGIN VERSION 0.1 QML_FILES MyThing.qml)
      
      target_link_libraries(foo PRIVATE bla Qt::Qml Qt::Gui) 

      By linking against bla I expect MyThing.qml to be available in the resources of the app. However that's not the case, because bla is discarded by the linker because it appears as not needed (nothing in foo references symbols in bla).

      Some toolchains default to "-as-needed", making the problem very not obvious. Now I guess this isn't strictly a Qt bug, but I still wonder if there's something Qt can do, if only document the pitfall.

      There is Q_IMPORT_QML_PLUGIN, but that appears to be only for static builds with plugins, but here I have neither a static build nor a plugin

       

       

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              nicolasfella Nicolas Fella
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes