This question has been raised repeatedly, but Visual Studio never ceases to challenge me.
We have an application that should be self-sufficient, i.e. independent of any third-party libraries. That's why we set everything statically using code generation flags MT(d).
The application depends on Qt, zlib, OpenSSLand DCMTK. All of these libraries were created as static libraries with MT(d). The application also uses some MFCnon-related code, so we should also reference it.
MFC turns on through
#include <afxwin.h>
I read somewhere that this should be the first inclusion in every file, but I'm not sure if this is true. In any case, the line is not included in each file, only one file includes it.
Here are the link errors:
Error 24 error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj) uafxcwd.lib
Error 22 error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) uafxcwd.lib
Error 23 error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmtd.lib(newaop.obj) uafxcwd.lib
Error 21 error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj) uafxcwd.lib
Here is the linker link .
I read a lot of streams on many sites, as well as this article from MSDN KB. But they don’t help me, since they all say that MFC libraries should be linked before CRT, but I can’t find a way to change the order of binding.
Any help is greatly appreciated.
Edit 1 : Using the trick from this topic actually solves the problem, but I still want to know what is wrong here.
Edit 2 : Using Visual Studio 2008 SP1 in Windows 7 and Qt 4.6.3