error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMT.

来源:互联网 发布:淘宝网茵曼女装 编辑:程序博客网 时间:2024/06/06 09:28

在vs2012 中将程序改为release 版本    点击所选项目--》properties-----》Configurations:  中选择release   然后从新编译工程即可;

环境:vs2012 中 在非MFC程序(使用standard window library)中,添加MFC支持,静态连接MFC库 发生以下错误
Error 1 error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined inLIBCMT.lib(new.obj)C:\Users\Administrator\Desktop\Tracker_release版本\Tracker删减版(无人脸检测)\Tracker\uafxcw.lib(afxmem.obj)
Error 3 error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)C:\Users\Administrator\Desktop\Tracker_release版本\Tracker删减版(无人脸检测)\Tracker\uafxcw.lib(afxmem.obj)
Error 2 error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMT.lib(delete.obj)C:\Users\Administrator\Desktop\Tracker_release版本\Tracker删减版(无人脸检测)\Tracker\uafxcw.lib(afxmem.obj)
Error 4 error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMT.lib(delete2.obj)C:\Users\Administrator\Desktop\Tracker_release版本\Tracker删减版(无人脸检测)\Tracker\uafxcw.lib(afxmem.obj)


解决方案:参考:https://support.microsoft.com/en-us/kb/148652

Solution One: Force Linker to Link Libraries in Correct Order

  1. On the Project menu, click Settings.
  2. In the Settings For view of the Project Settings dialog box, click to select the project configuration that is getting the link errors.
  3. On the Link tab, click to select Input in the Category combo box.
  4. In the Ignore Specific Default libraries box, insert the library names (for my example,uafxcw.lib;LIBCMT.lib). 

    Note The linker command-line equivalent in /NOD:<library name>.
  5. In the Additional Dependencies box, insert the library names. You must make sure that these are listed in order and as the first two libraries in the line (for my example,uafxcw.lib;LIBCMT.lib).





0 0
原创粉丝点击