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

Implement auto importing of plugins when building an application that uses a static build of Qt

XMLWordPrintable

    • Icon: User Story User Story
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • 6.0.0
    • None
    • Build System: CMake
    • None

      Currently when building and running a CMake Qt application using a static build of Qt, you get the following error:

      
      qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
      This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem
      

      This is because during a static build, plugins have to be explicitly initialised from within code by using the Q_IMPLORT_PLUGIN() macro.
      See https://doc.qt.io/QtForDeviceCreation/qtee-static-linking.html#building-a-static-application
      This is done automatically by qmake, but not by CMake.

      There is a pending patch at https://codereview.qt-project.org/#/c/243731/22 which adds such functionality for the CMake files created by qmake.

      We should add the same to the CMake files which are generated for the CMake Qt build which are then consumed by a CMake application.

      Perhaps something can be reused there.

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

            jcelerier Jean-Michaƫl Celerier
            alexandru.croitor Alexandru Croitor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes