Search code examples
c++qtqt5qt-quickqtdeclarative

Qt | Is this possible to use declarative and quick modules simultaneously


I have Qt5 project that successfully compiled against shared Qt libraries, but I get a lot of errors (about 130 errors) like * error: multiple definition of 'XXX' when compile it against static Qt libraries:

/usr/local/Qt-5.3.0/lib/libQt5Quick.a(qquickanimation.o): In function `_q_interpolateShortestRotation(double&, double&, double)':
qquickanimation.cpp:(.text+0x330): multiple definition of `_q_interpolateShortestRotation(double&, double&, double)'
/usr/local/Qt-5.3.0/lib/libQt5Declarative.a(qdeclarativeanimation.o):qdeclarativeanimation.cpp:(.text+0xd80): first defined here
/usr/local/Qt-5.3.0/lib/libQt5Quick.a(qquickanimation.o): In function `_q_interpolateClockwiseRotation(double&, double&, double)':
qquickanimation.cpp:(.text+0x3c0): multiple definition of `_q_interpolateClockwiseRotation(double&, double&, double)'
/usr/local/Qt-5.3.0/lib/libQt5Declarative.a(qdeclarativeanimation.o):qdeclarativeanimation.cpp:(.text+0xe10): first defined here

Almost all multiple definitions detected in pairs:

  • libQt5Declarative, libQt5Quick
  • libQt5Declarative, libQt5Qml

I need to libQt5Declarative only for using MessageDialog in my qml

My .pro file:

QT       += quick declarative widgets network xml xmlpatterns multimedia

TARGET = MyApp
TEMPLATE = app

SOURCES += ...
HEADERS  += ...
OTHER_FILES += ...
RESOURCES += ...

CONFIG += static

My questions are:

  • Why it successfully compiles against shared Qt, but fails when I compile against static Qt?
  • Is this possible to use declarative and quick modules simultaneously?
  • I compiled static Qt libraries by myself and maybe I done this incorrect, Is Qt have official static libraries package?

Solution

  • Qt Declarative is provided for Qt 4 compatibility. I presume it is not designed to be linked against by new Qt 5 projects. It appears that it has been subsumed by Qt QML and Qt Quick.

    Static libraries have no facility for specifying which of their symbols are exported and which are not, so identical private symbols defined in two different static libraries may conflict.