error LNK2005: "void * __cdecl operator new(unsigned int)" ([email protected]@Z) 已经在 LIBCMTD.lib(new.obj) 中

在编译文章:

使用GetAdaptersAddresses函数获取物理MAC地址中的代码时,出现以下错误:

错误 1 error LNK2005: “void * __cdecl operator new(unsigned int)” ([email protected]@Z) 已经在 LIBCMTD.lib(new.obj) 中定义 F:\CcProjects\获取网卡物理地址MAC地址\获取网卡物理地址MAC地址\uafxcwd.lib(afxmem.obj) 获取网卡物理地址MAC地址

环境:Windows7+VS2010

  环境:在非MFC程序(使用standard windows library)中,添加MFC支持,静态链接MFC库。

  发生以下错误:

uafxcw.lib(afxmem.obj) : error LNK2005: “void * __cdecl operator new(unsigned int)” ([email protected]@Z) already defined in LIBCMT.lib(new.obj)

uafxcw.lib(afxmem.obj) : error LNK2005: “void __cdecl operator delete(void *)” ([email protected]@Z) already defined in LIBCMT.lib(delete.obj)

uafxcw.lib(afxmem.obj) : error LNK2005: “void * __cdecl operator new[](unsigned int)” ([email protected]@Z) already defined in LIBCMT.lib(new2.obj)

问题产生原因,CRT库和MFC库链接时顺序有误:

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.

  具体解决方法:(另一种解决方法参见最后链接,本人未测试)

  在vs2010项目设置中【Linker】-【input】-【additional dependencies】追击nafxcw.lib,libcmt.lib,Debug下,追加Nafxcwd.lib,libcmtd.lib。

  再次编译通过,但出现

  LINK : warning LNK4098: defaultlib ‘uafxcw.lib’ conflicts with use of other libs; use /NODEFAULTLIB:library

  在【Linker】-【input】-【Ignore specific library】中追加uafxcw.lib或Debugg版本的uafxcwd.lib。

操作方法如下图:

在解决方案资源管理器中选中对应的项目

点击项目菜单》属性,或者是直接在项目上单击鼠标右键》属性

展开配置属性》链接器,选中输入,点击附加依赖项右侧的下拉框,在弹出的菜单中点击编辑

输入附加依赖项,点击确定。

时间: 2024-12-11 14:56:10

error LNK2005: "void * __cdecl operator new(unsigned int)" ([email protected]@Z) 已经在 LIBCMTD.lib(new.obj) 中的相关文章

uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)"解决办法

如果在编译MFC程序的时候出现下列及类似的错误: 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" ([email protected]@Z) 已经在 LIBCMTD.lib(new.obj) 中定义1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete

MFC程序出现uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)解决办法

在同一个地方摔倒两次之后,决定记录下来这个东西. 问题 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" ([email protected]@Z) 已经在 LIBCMTD.lib(new.obj) 中定义1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator del

VC编译错误:msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::t.... 已经在 libcmtd.lib(typinfo.obj) 中定义

1>msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" ([email protected]@[email protected]@@Z) 已经在 libcmtd.lib(typinfo.obj) 中定义1>msvcrtd.lib(ti_inst.obj) : error LNK2005: "

2>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义

使用VS2010,在FireBreath里面调用ortp库和Speex库.编译的时候出现错误: 2>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义 事实上有非常多类似的打印. "属性"->"链接器"->"输入"->"忽略特定默认库" 将LIBCMTD.lib写入就能够了:

2>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义

使用VS2010,在FireBreath里面调用ortp库和Speex库,编译的时候出现错误: 其实有很多类似的打印. "属性"->"链接器"->"输入"->"忽略特定默认库" 将LIBCMTD.lib写入就可以了:

1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _strncmp 已经在 libcmtd.lib(strncmp.obj) 中定义

原来在MFC ActiveX里面也是可以使用eXosip库的.... 悲剧总是在不经意间就发生在我的身上, 这个错误,莫名其妙的就出现了,同事编译好的eXosip库,在vs2010用的好好的,我在MFC里面去用就出现了这样的问题: 实例很多种方法,大部分说的就可MTD相关: 后来对比了同事的项目属性,使用的不是这个,是MT,打开他编译库的工程,发现也不是MTD,于是将工程拿出来,重新使用MTD编译出来的库,放在我那个里面使用就没有问题了.

error LNK2005: DDX_Control 已经在 uafxcwd.lib(wincore2.obj) 中定义

编译错误提示: 1>afxnmcdd.lib(wincore2.obj) : error LNK2005: "void __stdcall DDX_Control(classCDataExchange *,int,class CWnd &)" ([email protected]@[email protected]@[email protected]@@Z)already defined in nafxcwd.lib(wincore2.obj) 1>afxnmcdd

VS报错 error LNK2005: [email protected] 已经在 MSVCRTD.lib(dllmain.obj) 中定义

链接报错: 错误 33 error LNK2005: [email protected] 已经在 MSVCRTD.lib(dllmain.obj) 中定义 E:\客户问题\w_王鹏\EventLibTest_TibrvAlternative_MultiEnv-4-0.3将 DTSSysEvent.xml做为单独参数传给每个环境\EventLibTest_TibrvAlternative_MultiEnv\Win32 \APPFL\EventLibMultiEnvDLL\mfcs100d.lib(

Error: couldn't add user: No role named [email protected] :

1.执行下面Error: couldn't add user: No role named [email protected] : db.createUser( { user: "dsform", pwd: "123456", customData: { employeeId: 12345 }, roles: [ { role: "readWrite", db: "dsform" }, "readWrite"