[Interest] Qt5 +CLR -> linker error LNK2005

Thiago Macieira thiago.macieira at intel.com
Tue Feb 5 06:34:02 CET 2013


On segunda-feira, 4 de fevereiro de 2013 10.49.59, Franz Hirschbeck wrote:
> 1>file2.obj : error LNK2005: "public: __cdecl `public: __cdecl
> QList<class QString>::QList<class QString>(class QList<class QString>
> const &)'::`5'::Cleanup::Cleanup(struct QListData::Data *)"
> (??0Cleanup@?4???0?$QList at VQString@@@@QEAA at AEBV1@@Z at QEAA@PEAUData at QListData@
> @@Z) already defined in file1.obj

What's that "5" over there?

> The error is located in <QtCore/QList>.
> 
> The "Cleanup" struct is defined, declared and instantiated within the
> templated constructor of the class QList. If it is used in 2 independent
> .cpp files with the same template parameter than it should be created in
> both objects. But the linker can see that they are identical.
> When the compiler was called with the /clr flag this results in the
> linker error afterwards.

Conclusion: compiler / linker bug.

> I tracked this down to a very simple example which is attached.
> 
> I am not sure if this is a bug from the compiler, a limitation of clr or
> if the Qt code itself is not valid. To me the code looks correct and I
> don't know of a limitation of CLR in that case.

Either way, it's not Qt's fault. If the compiler can't compile completely 
valid C++ code and link it, then you should report it to the vendor.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130204/7ba2def1/attachment.sig>


More information about the Interest mailing list