error LNK2005: operator new(unsigned int) already defined in LIBCMTD.lib
uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
這個是 uafxcwd.lib 與 libcmtd.lib link 順序的問題。一般來說 uafxcwd.lib 要比 libcmtd.lib 更早 link
解法是手動強制指定它們的 link order。以下是在 stack overflow 看到的解法:
The CRT libraries use weak external linkage for the new, delete, and DllMain functions. The MFC libraries also contain new, delete, and DllMain functions. These functions require the MFC libraries to be linked before the CRT library is linked. http://support.microsoft.com/kb/148652
Solution based on VS2005
go to project>properties>configuration properties>linker>input
add to "Additional dependency" -> Nafxcwd.lib Libcmtd.lib
add to "ignore specific library" -> Nafxcwd.lib;Libcmtd.lib
order of libraries is important( Nafxcwd.lib;Libcmtd.lib).
留言
張貼留言