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

QtQuickControls2 MacOS build error when modifying source

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: P4: Low P4: Low
    • None
    • 5.15.1
    • None
    • macOS

      If you add any overridden function to the header file to any component, and its implementation, i am getting build error on MacOS platform. There are no build errors on other platforms.

      Steps to reproduce

      1. git clone git://code.qt.io/qt/qtquickcontrols2.git and git checkout 5.15.1
      2. Add any overloaded function to any component, for example i added hoverLeaveEvent into QQuickSplitView (patch in attachment)
      3. Try to compile and you will get linker error when trying to link qtquicktemplates2plugin.o.
      Undefined symbols for architecture x86_64:
        "QQuickSplitView::hoverLeaveEvent(QHoverEvent*)", referenced from:
            vtable for QQmlPrivate::QQmlElement<QQuickSplitView> in qtquicktemplates2plugin.o
      

       4. This happened because src/imports/templates/Makefile has the following order of paths to libraries:

       LIBS          = $(SUBLIBS) -F/Volumes/Disk/Qt/5.15.1/clang_64/lib -F/Users/dev/projects/QtDev/tmp/qtquickcontrols2/lib -framework QtQuick -framework QtGui -framework AppKit -framework Metal -framework QtQmlModels -framework QtQml -framework QtNetwork -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL -framework QtQuickTemplates2 -F/Volumes/Disk/Qt/5.15.1/clang_64/lib -framework QtQuick -framework QtGui -framework AppKit -framework Metal -framework QtQmlModels -framework QtQml -framework QtNetwork -framework QtCore -framework DiskArbitration -framework IOKit  
      

      Why is the path to Qt libs included twice? Because of this, we have a bug that priority of the original library QtQuickControls2 have first path -F/Volumes/Disk/Qt/5.15.1/clang_64/lib without my implementation of my function overloaded function.

      Workaround how to fix that is modify src/imports/templates/templates.pro file, just and following lines to the end of the file.

      macx {
          QT -= core gui qml quick
      }
      

      This will change the order of the paths in Makefile, my implementation will be included before Qt, and compilation will be successful.

      LIBS          = $(SUBLIBS) -F/Users/dev/projects/QtDev/tmp/qtquickcontrols2/lib -F/Volumes/Disk/Qt/5.15.1/clang_64/lib -framework OpenGL -framework AGL -framework QtQuickTemplates2 -F/Volumes/Disk/Qt/5.15.1/clang_64/lib -framework QtQuick -framework QtGui -framework AppKit -framework Metal -framework QtQmlModels -framework QtQml -framework QtNetwork -framework QtCore -framework DiskArbitration -framework IOKit  
      

      Also tested on earlier versions of Qt.

        1. splitview_example.patch
          1 kB
          Igor Bugaev
        2. templates_fix.pro.patch
          0.3 kB
          Igor Bugaev
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            freed Igor Bugaev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes