View Full Version : Multi defined QVector<float>::QVector<float>

6th May 2013, 02:49

I have the following codes:

#include <QVector>

template <typename Type>
class MyVector : public QVector<Type>

template class IMPORT_EXPORT MyVector<float>;
typedef MyVector<float> MyFloatVector;

The above code is built into a dll library, with IMPORT_EXPORT properly defined.

Then I have another dll using QVector<float> directly, such as

#include <QVector>

class AnotherClass

QVector<float> foo() const {
return QVector<float>();


When linking them together, I got QVector<float>::QVector<float> already defined error. This only happens on Windows. Linux is fine.

Can someone tell me what is the problem?

Many thanks.

6th May 2013, 08:58
Mark the method in AnotherClass as inline.