[solved] Compiler errors after transition from Qt4.x project to Qt5.x on OSX



  • I've tried to change a project that just runs/compiles fine with Qt4.8.x (gcc and clang) to Qt5.0.x (tried clang 5.0.1 and clang 5.0.2).
    Checked for changes to .PRO file from
    http://qt-project.org/wiki/Transition_from_Qt_4.x_to_Qt5
    and used the fixqt4headers.pl script, which didn't find any includes that needed a change.

    On compiling I receveive an error from one of the qmake generated moc files:

    @
    clang++ -c -pipe -mmacosx-version-min=10.6 -g -gdwarf-2 -Wall -W -fPIE -DHC_PROGRAMVERSION="0.1.0" -DHC_GITHASH="9f49f3a1ed09e462b1051e790e3898fa57467550" -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../Qt5.0.2/5.0.2/clang_64/mkspecs/macx-clang -I../../../Dropbox/private/Qt/SolMan -I../../../devtools/taglib-bin/include/taglib -I../../../devtools/boost_1_53_0 -I../../../Qt5.0.2/5.0.2/clang_64/include -I../../../Qt5.0.2/5.0.2/clang_64/include/QtWidgets -I../../../Qt5.0.2/5.0.2/clang_64/lib/QtWidgets.framework/Versions/5/Headers -I../../../Qt5.0.2/5.0.2/clang_64/include/QtGui -I../../../Qt5.0.2/5.0.2/clang_64/lib/QtGui.framework/Versions/5/Headers -I../../../Qt5.0.2/5.0.2/clang_64/include/QtCore -I../../../Qt5.0.2/5.0.2/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -I. -I. -o moc_itunesconnector.o moc_itunesconnector.cpp
    In file included from moc_itunesconnector.cpp:9:
    In file included from ./../../../Dropbox/private/Qt/SolMan/itunesconnector.h:4:
    In file included from ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/QObject:1:
    In file included from ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qobject.h:55:
    ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qmetatype.h:642:5: error: implicit instantiation of undefined template 'QStaticAssertFailure<false>'
    Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
    ^
    ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qglobal.h:642:47: note: expanded from macro 'Q_STATIC_ASSERT_X'
    #define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
    ^
    ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qglobal.h:641:76: note: expanded from macro 'Q_STATIC_ASSERT'
    enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, LINE) = sizeof(QStaticAssertFailure<!!(Condition)>)}
    ^
    ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qmetatype.h:656:12: note: in instantiation of function template specialization 'qMetaTypeId<QList<QUrl> *>' requested here
    return qMetaTypeId(dummy);
    ^
    moc_itunesconnector.cpp:137:50: note: in instantiation of function template specialization 'qRegisterMetaType<QList<QUrl> >' requested here
    reinterpret_cast<int>(_a[0]) = qRegisterMetaType< QList<QUrl>
    >(); break;
    ^
    ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qglobal.h:635:28: note: template is declared here
    template <bool Test> class QStaticAssertFailure;
    ^
    In file included from moc_itunesconnector.cpp:9:
    In file included from ./../../../Dropbox/private/Qt/SolMan/itunesconnector.h:4:
    In file included from ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/QObject:1:
    In file included from ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qobject.h:55:
    ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qmetatype.h:534:82: error: no member named 'qt_metatype_id' in 'QMetaTypeId<QList<QUrl> *>'
    static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
    ~~~~~~~~~~~~~~~~^
    ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qmetatype.h:643:29: note: in instantiation of member function 'QMetaTypeId2<QList<QUrl> *>::qt_metatype_id' requested here
    return QMetaTypeId2<T>::qt_metatype_id();
    ^
    ../../../Qt5.0.2/5.0.2/clang_64/include/QtCore/qmetatype.h:656:12: note: in instantiation of function template specialization 'qMetaTypeId<QList<QUrl> *>' requested here
    return qMetaTypeId(dummy);
    ^
    moc_itunesconnector.cpp:137:50: note: in instantiation of function template specialization 'qRegisterMetaType<QList<QUrl> >' requested here
    reinterpret_cast<int>(_a[0]) = qRegisterMetaType< QList<QUrl>
    >(); break;
    ^
    2 errors generated.
    make: *** [moc_itunesconnector.o] Error 1
    21:40:53: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project SolMan (kit: Qt 5.0.2 Desktop clang 64bit)
    When executing step 'Make'
    @

    The build directory was completely empty before compiling, no left traces from 4.8.x compiles.

    What else do I need to change for a successful compile? And yes, QList and QUrl are included.


  • Lifetime Qt Champion

    Hi,

    Do you have the Q_DECLARE_METATYPE statements somewhere in your code ?



  • No, I didn't even know what that was until I got those errors.



  • I've "filed a bug":https://bugreports.qt-project.org/browse/QTBUG-31002 because it can be reproduced with a quite small test project.


  • Lifetime Qt Champion

    Do you also have that with Qt 5.1 ?



  • Yes, even with the latest version from Git.
    If I read the first answer to the bug-report right, then it is a bug.



  • Bug was "fixed":https://codereview.qt-project.org/#change,56445
    Didn't have the time to pull/compile but I will mark this here as solved anyway.



  • Pulled/compiled qt5 from git and yes, the bug is gone :-D


  • Lifetime Qt Champion

    Great ! :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.