[odb-users] Qt6: error: redefinition of 'class odb::access::container_traits<QList<T>

CETONI GmbH - Uwe Kindler uwe.kindler at cetoni.de
Tue Nov 14 10:20:35 EST 2023


Hi,

we are just switching from Qt5 to Qt6 and therefore upgraded from QDB 
2.4.0 to 2.5.0. If we compile our library with Qt5, everything is fine. 
If we compile with Qt6, we see lots of these issues:

...
../../../../mingw1120_64_qt6/usr/include/odb/qt/containers/qvector-traits.hxx:16:17: 
error: redefinition of 'class odb::access::container_traits<QList<T> >'
    16 |   class access::container_traits<QVector<T> >

...

This is caused by the include files of the generated Class-odb.h files:

#if ODB_QT_VERSION != 2047500 // 2.5.0-b.25
#  error ODB and C++ compilers see different libodb-qt interface versions
#endif
#include <odb/qt/containers/qlist-traits.hxx>
#include <odb/qt/containers/qvector-traits.hxx>
...

The generated header files include the odb container traits files such 
as qlist-traits.hxx and qvector-traits.hxx. The problem here is, that in 
Qt6 QVector is just a typedef for QList (snipped from Qt source):

...
template<typename T> using QVector = QList<T>;
...

I could fix this by wrapping the code in qvector-traits.hxx into:

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)

...

#endif

But I'm not sure, if this is the right solution.





More information about the odb-users mailing list