Reputation: 21
I'm updating a project from VS2008 to VS2010 and I'm getting this error:
uafxcwd.lib(afxwinappex.obj) : error LNK2005: "public: virtual struct CRuntimeClass * __thiscall CWinAppEx::GetRuntimeClass(void)const " (?GetRuntimeClass@CWinAppEx@@UBEPAUCRuntimeClass@@XZ) already defined in WinAppEx.obj
I've tried everything I can think of. uafxcwd.lib is in the "Additional Dependencies" and "Ignore Specific Default Libraries" settings in the Linker. For some reason it doesn't seem to ignore the uafxcwd.lib library.
Any help would be greatly appreciated.
Upvotes: 1
Views: 1469
Reputation: 21
Fixed it. The issue is that uafxcwd.lib in VS2010 introduced a new class cwinappex. This was identically named to the class I had made, causing the conflict.
Who'd have thunk it?
Upvotes: 1
Reputation: 1609
I have had this problem long time ago and I found a project that had proper setting and compiles without errors. I have also made some notes but I do not remember how (where) I got the solution.
Here it is:
You are using C runtime libraries in the MFC project and libraries are linked in the wrong order. CRT and MFC libraries contain new, delete and DLLMain where CRT are using weak external link. All functions in the MFC libraries have to be linked before CRT.
In order to achieve this, do the following:
In the project setting, link, input, go to the ignore libraries and add Libcmtd.lib. This will exclude Libcmtd.lib from the link process.
Since you need it, it has to be included. You can force it by adding library in the Additional Dependencies box. BUT add libraries in following order: uafxcw.lib LIBCMT.lib.
As yu can see, uafxcw.lib is BEFORE LIBCMT.lib. this should fix your problem.
Upvotes: 1