0

When trying to compile this project under Win7 with Visual Studio 2010 and Qt5.2/Qt3D, I'm getting the following error:

error LNK1169: one or more multiply defined symbols found   C:\OculusQt3D\oculusqt3d\build\Debug\OculusQt3D.exe 1
error LNK2005: "public: __thiscall QArray<class QVector3D,8>::~QArray<class QVector3D,8>(void)" (??1?$QArray@VQVector3D@@$07@@QAE@XZ) already defined in mdstate.obj    C:\OculusQt3D\oculusqt3d\build\Qt53Dd.lib(Qt53Dd.dll)
error LNK2005: "public: __thiscall QArray<class QVector3D,8>::QArray<class QVector3D,8>(void)" (??0?$QArray@VQVector3D@@$07@@QAE@XZ) already defined in Qt53Dd.lib(Qt53Dd.dll)  C:\OculusQt3D\oculusqt3d\build\MULTIBILLBOARD_LIBRARY.lib(databundle.obj)
error LNK2005: "public: int __thiscall QArray<class QVector3D,8>::size(void)const " (?size@?$QArray@VQVector3D@@$07@@QBEHXZ) already defined in mdstate.obj C:\OculusQt3D\oculusqt3d\build\Qt53Dd.lib(Qt53Dd.dll)

The mentioned files are mdstate.h / mdstate.cpp and databundle.h / databundle.cpp and qarray.h / qarray.cpp

After googling, there are quite a few possibilities where this error could originate from, but I can't get my head around this case.

Usually this is caused by including a .cpp instead of a header, accidentally including a file multiple times, missing include guards and stuff like that, which is not the case here.

So, does someone know what's the problem here?

Dreiven
  • 687
  • 3
  • 9
  • 22
  • Can you reproduce it on a more recent Visual C++ version? Those functions are templates, they're supposed to be marked `selectany` by the compiler so that multiple definitions don't cause link errors (the C++ Standard states that multiple definitions of template functions are allowed, if and only if all definitions are equivalent) – Ben Voigt Mar 27 '14 at 14:58
  • Yes, I generated the project for Visual Studio 2012 with CMake under Win7 and get the same error when I try to run it. (Plus a new error with libovrd.lib) – Dreiven Mar 27 '14 at 16:32
  • Can you show some dumpbin output from the files in question (just the lines related to these functions, and maybe any others from the same class that are acting differently) – Ben Voigt Mar 27 '14 at 16:47
  • Also, it looks like there may be DLL imports involved. Check on any macros related to creation-vs-use of the Qt DLL, that might affect a later `dllimport` vs `dllexport` keyword. – Ben Voigt Mar 27 '14 at 16:49

0 Answers0