VC缺省链接库的顺序不对导致链接错误error LNK2005: "void __cdecl operator delete(void *)"


MFC static Library和Code Generation/MultiThread选项时,链接总出现问题:
nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpmt.lib(delop.obj)
nafxcw.lib(afxmem.obj) : warning LNK4006: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpmt.lib(delop.obj); second definition ignored

解决方法:
调整库nafxcw.lib,libcpmt.lib的顺序,库nafxcw.lib必须先于库libcpmt.lib.但缺省时,vc先编译那个文件就先链接那个库,可能导致libcpmt.lib先链接而nafxcw.lib后链接.此时,可以在project setting中先忽略这两个库nafxcw.lib,libcpmt.lib

你可能感兴趣的:(VC缺省链接库的顺序不对导致链接错误error LNK2005: "void __cdecl operator delete(void *)")