Nominate our 2022 Qt Champions!

Qt5, cmake, clang and macOS

  • Hey everyone!

    Since updating everything I have installed via brew, I can no longer build our open-source project.
    So first of all here are the version of everything I use:

    g++: Apple clang version 12.0.0 (clang-1200.0.32.29)
    qt@5: qt5.12.2 (freshly installed via brew)
    cmake: cmake version 3.19.5

    Here is the CMakeLists.txt we use to link qt in our project.

    Since the latest update I get a bunch of errors ranging from:

    /usr/local/Cellar/qt/5.15.2/lib/QtWidgets.framework/Headers/qstyleoption.h:500:9: error: 'deprecated' attribute cannot be applied to types
    typedef Q_DECL_DEPRECATED QStyleOptionToolBox QStyleOptionToolBoxV2;
    /usr/local/include/QtCore/qcompilerdetection.h:1152:31: note: expanded from macro 'Q_DECL_DEPRECATED'
    #  define Q_DECL_DEPRECATED [[deprecated]]


    In file included from ../plugins/gui/src/channel_manager/channel_item.cpp:1:
    In file included from ../plugins/gui/include/gui/channel_manager/channel_item.h:28:
    In file included from /usr/local/Cellar/qt/5.15.2/lib/QtCore.framework/Headers/QList:1:
    In file included from /usr/local/Cellar/qt/5.15.2/lib/QtCore.framework/Headers/qlist.h:1196:
    /usr/local/include/QtCore/qstringlist.h:85:51: error: no template named 'QListSpecialMethodsBase'; did you mean 'QListSpecialMethods'?
    template <> struct QListSpecialMethods<QString> : QListSpecialMethodsBase<QString>


    /usr/local/include/QtCore/qbytearraylist.h:83:45: error: use of undeclared identifier 'self'
        { return QtPrivate::QByteArrayList_join(self(), &sep, 1); }

    I have absolutely no idea what's wrong and the errors only occurred after I updated everything. Even in our CI we have on GitHub, it is no longer building properly on macOS.

    I am really stuck. My guess is that we are doing something wrong from cmake, but I cannot figure out what.

    I also had to add the Qt5_DIR to theCMakeLists. txt, so qt5 can be found at all. I did not have to do that before.

    set (Qt5_DIR "/usr/local/opt/qt/lib/cmake" )

    For some reason none of the above errors occur on Ubuntu and not macOS, here everything works fine.

  • Moderators

    It looks like you have a Qt 6 build in /usr/local/include, and header files from there get mixed with the Qt 5.12.2 in /usr/local/Cellar/qt.

    set (Qt5_DIR "/usr/local/opt/qt/lib/cmake" )

    This might be the culprit. Shouldn't this be /usr/local/Cellar/qt/5.15.2 ?

  • Cannot believe that this solved all my problems. I had to delete all qt files manually though. Uninstalling them via brew did not do the trick.

    Thank you so much!

Log in to reply