Important: Please read the Qt Code of Conduct -

[SOLVED] Build problems switching from Qt 5.3 to Qt 5.4 - Get redeclaration and redefinition errors

  • Hi,

    when try to complie with new Qt 5.4 our project won't build. (Qt 5.3 is well working)
    Using Qt for Windows, Desktop Application, MinGW 32bit 4.9.1

    We got


    in qdeclarative.h Line 61

    many errors like

    redefinition of 'template<class T> int qmlRegisterUncreatableType(const char*, int, int, const char*, const QString&)'
    int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)


    also from qdeclarative.h


    _redefinition of 'struct QMetaTypeId<QObject*>'
    struct QMetaTypeId< TYPE > _
    in qmetatype.h

    Didn't found these issues already discussed so i hope someone can help. Right now I've no idea.
    Thought leap from 5.3 to 5.4 shouldn't be such a problem.


  • Moderators

    Hi, and welcome to the Qt Dev Net!

    Did you clean your build directory before switching versions?

  • Hi there,

    yes, we did.
    We also (re)installed Qt 5.4 and updating to new QtCreator 3.3.
    Didn't helped.

    New projects or demo projects build well with new Qt .5.4.

  • Moderators

    Please try to remove old Makefiles in addition to your cleaning.

  • We already did that too.

    We just used the "raw" source codes files an try to build.
    No make, moc, or what ever (should) have been left from old Qt 5.3 build.

    Same problems...

  • I haven't see this. I use almost the identical configuration except for my version of MinGW, 4.8.2 in my case. I build from source.

    Is your copy of MinGW the one provided with Qt 5.4.0?

    Do you still have the previous version of Qt (5.3) on the same computer? Is it possible that you are mixing between the two versions of MinGW (i.e. using the new compiler but including headers or other files from the old version?).

  • The MinGW 4.9.1 comes from the Qt maintenance tool / package updater. Bundled to the Qt 5.4 Version

    I do have both Qt Version on my system an i can switch between the severals build kits inside Qt Creator.

    Qt 5.3 with MinGW 4.8.2 works, Qt 5.4 with MinGW 4.9.1 didn't.

    Well, I'll try to test Qt 5.4 with the old MinGW 4.8.2 Version...

  • I could try the same (update MinGW to 4.9.1) to verify. I have never had a problem with past versions of MinGW so I am skeptical that this is the cause.

    It is not as easy as switching MinGW. Qt would need to be re-compiled to be sure there is no other side effects.

  • Just tried a fresh Qt 5.4 Installation with only MinGW 4.9.1...

    Same problem...

    Damm, I have no idea at all what's the problem....

  • Moderators

    I just noticed that the problem header is qdeclarative.h.

    Are you mixing Qt Quick 1 with Qt Quick 2? If so, stick to one version only (preferably Qt Quick 2), and remove all traces of the other version from your code. Mixing versions isn't supported.

  • Well, we use several QML-Files and we do mix QtQuick 2.0 / 2.1 and 2.2....

    But no Qt Quick 1.0 as far as I can see...

    Mixing Qt Quick 2.x also a problem ?

  • Moderators

    [quote author="Florian.Preiss" date="1424354633"]But no Qt Quick 1.0 as far as I can see...[/quote]Do you use any classes that are called QDeclarative[X]? If so, you need to replace them with QQml[X] or QQuick[X].

    Look through your error messages again. How is qdeclarative.h getting included in your project?

    [quote author="Florian.Preiss" date="1424354633"]Mixing Qt Quick 2.x also a problem ?[/quote]Mixing Qt Quick 2.x should be fine, AFAIK.

  • The hint with "decalrative.h" has finally solved the issue or at least helped to identify the problem.

    We hade two classes which used "QDevlarativeItem" like this

    printsystem_controller::printsystem_controller(QDevlarativeItem *parent) :

    We changed it to

    printsystem_controller::printsystem_controller(QObject *parent) :

    and the build works.
    Fortunately there was no need for "QDevlarativeItem" at this point.

    We then hat also this problem


    but there we could change the settings of the CentralWidget to make it work.

    Thanks for helping

  • Moderators

    QDeclarativeItem has been replaced by QQuickItem in QtQuick 2.

Log in to reply