Question

I'm currently trying to build and run a QtQuick 2 application, but a duplicate symbol error appears :

ld: 55 duplicate symbols for architecture i386 and here are some duplications :

duplicate symbol __ZTS16QActionAnimation in:
/Users/momo/Qt5.2.1/5.2.1/ios/lib/libQt5Quick_iphonesimulator_debug.a(qquickanimation.o)    /Users/momo/Qt5.2.1/5.2.1/ios/lib/libQt5Declarative_iphonesimulator_debug.a(moc_qdeclarativeanimation_p_p.o)

duplicate symbol __Z30_q_interpolateShortestRotationRdS_d in:
/Users/momo/Qt5.2.1/5.2.1/ios/lib/libQt5Declarative_iphonesimulator_debug.a(qdeclarativeanimation.o)
/Users/momo/Qt5.2.1/5.2.1/ios/lib/libQt5Quick_iphonesimulator_debug.a(qquickanimation.o)

duplicate symbol __Z31_q_interpolateClockwiseRotationRdS_d in:
/Users/momo/Qt5.2.1/5.2.1/ios/lib/libQt5Declarative_iphonesimulator_debug.a(qdeclarativeanimation.o)
/Users/momo/Qt5.2.1/5.2.1/ios/lib/libQt5Quick_iphonesimulator_debug.a(qquickanimation.o)

duplicate symbol __Z38_q_interpolateCounterclockwiseRotationRdS_d in: /Users/momo/Qt5.2.1/5.2.1/ios/lib/libQt5Declarative_iphonesimulator_debug.a(qdeclarativeanimation.o)   /Users/momo/Qt5.2.1/5.2.1/ios/lib/libQt5Quick_iphonesimulator_debug.a(qquickanimation.o)

Here are the different includes of project files :

main.cpp :

#include <QtGui/QGuiApplication>
#include <QQmlContext>
#include <QScreen>
#include <QRect>
#include "qtquick2applicationviewer.h"
#include "dataobject.h"

int main(int argc, char *argv[])
{
    ...
}

dataobject.cpp :

#include "dataobject.h"

 DataObject::DataObject(QObject *parent)
     : QObject(parent)
 {
 }

 ...

dataobject.h :

#ifndef DATAOBJECT_H
#define DATAOBJECT_H

#include <QObject>

class DataObject : public QObject
{
    ...
};

 #endif // DATAOBJECT_H

What I found weird is that there are many duplicate symbols but not in my files... This happend only when running with iOS, not with desktop (either mac or windows) nor Android.

Is there something to change in xcode project ?

Thanks in advance

Was it helpful?

Solution 2

I found the origin of the problem.

I was doing QT += declarative in my .pro file but wasn't using it elsewhere (I was using QDeclarativeView before using QQuickView).
Removing it solved my problem. I don't know why it was causing the problem, prehaps because it was not used (I checked other .pri in my project but none of the other contained it).

OTHER TIPS

I would suggest following these steps to find out if there is something wrong with duplicates

  • First check your Project by opening Build Phases->Compile Sources and see if there are any duplicates on your classes.
  • If that doesn't work try deleting your derived data, and clean your product on XCode.
  • Else remove all Compile Sources and add all .m files to your project again

Hope this will help!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top