VC++常规错误之17:1>nafxcwd.lib(afxmem.obj) : error LNK2005

(1)错误案例:在写日志程序中出现,工程是MFC程序(注:win32控制台应用程序,不会出现这种错误,当然是不支持MFC库的那种)

(2)错误原因:如下能看出一点眉目,重定义了.在使用***.obj时,已经在***.lib库中定义了.

摘抄:

上网搜了下,是CRT库与MFC库的冲突,解决方法是:让程序先链接Nafxcwd.lib,然后再链接Libcmtd.lib

you've got to change the order inwhich the libraries are linked. This is a bit tricky, since the library are linked automatically, without you explicitly specifying them.

So, first step, tell the linker to ignore the implicit libraries: Project/Setting/Linker, Input Tab, and put "Nafxcwd.lib Libcmtd.lib" in the "Libraries to Ignore" box.

Next, on the same page, in the Object/library Modules box, put the same to libraries. (in you still get the same error, try reversing them on this line)

可以从错误信息里看到,操作符new,delete,delete[]已经在LIBCMTD.lib中定义了,这跟C编译时使用的默认库与MFC运行时的默认编译库编译时链接顺序有关,我们可以手动的改变两个库的编译顺序就能解决这个定义冲突问题。

(3)错误现场:

1>正在链接...
1>nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" () 已经在 LIBCMTD.lib(new.obj) 中定义
1>nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" () 已经在 LIBCMTD.lib(dbgdel.obj) 中定义
1>nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" () 已经在 libcpmtd.lib(newaop.obj) 中定义
1>nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" () 已经在 LIBCMTD.lib(delete2.obj) 中定义
1>C:\Documents and Settings\Administrator\桌面\多线程写日志怎样写\写日志1\Debug\写日志1.exe : fatal error LNK1169: 找到一个或多个多重定义的符号

(4)错误解决办法:

中文

项目--属性 ---连接器---输入

附加依赖项    空格Nafxcwd.lib Libcmtd.lib

忽略指定库    空格Nafxcwd.lib Libcmtd.lib

清除项目。重新编译。搞定

VC++常规错误之17:1>nafxcwd.lib(afxmem.obj) : error LNK2005的更多相关文章

  1. VC编译错误: Nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12已经在dllmain.obj 中定义

    错误: Nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12已经在dllmain.obj 中定义 解决: 打开项目属性对话框, C/C++ -& ...

  2. (转+原)VC编译错误:uafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) 已经在 LIBCMT.lib(new.obj) 中定义

    参考网址:http://zhanyonhu.blog.163.com/blog/static/16186044201023094754832/ 1>uafxcw.lib(afxmem.obj) ...

  3. 【VS开发】uafxcwd.lib(afxmem.obj) : error LNK2005: 已经在 LIBCMTD.lib(new.obj) 中定义错误解决方案

    如果在编译MFC程序的时候出现下列及类似的错误: 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator ...

  4. uafxcwd.lib(afxmem.obj) : error LNK2005 解决方法

    项目为非MFC,但要用到MFC的库,使用过程中遇到的问题总结一下 uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl opera ...

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

    如果在编译MFC程序的时候出现下列及类似的错误: 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator ...

  6. Solve Error: nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)

    Error: nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)&quo ...

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

    在同一个地方摔倒两次之后,决定记录下来这个东西. 问题 1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl opera ...

  8. mfcs100d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)

    转自VC错误:http://www.vcerror.com/?p=55 问题描述: mfcs100d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 al ...

  9. libcmt.lib(crt0dat.obj) : error LNK2005: _amsg_exit 已经在 MSVCRTD.lib(MSVCR110D.dll) 中定义

    问题描述(VC2012): 1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: 默认库"libcmt.lib"与其他库的使用冲突:请 ...

随机推荐

  1. kali_install_complete_no_sound

    参考:http://tieba.baidu.com/p/4343219808 用pulseaudio --start会看到一些信息,提示类似root用户之类的 我是用下面这个方法搞定的 systemc ...

  2. C# 版本和.NET 版本以及VS版本的对应关系

    https://en.wikipedia.org/wiki/C_Sharp_(programming_language)#Versions http://stackoverflow.com/quest ...

  3. 解决 docker: Error response from daemon: ... : net/http: TLS handshake timeout.

    参考:解决 Docker pull 出现的net/http: TLS handshake timeout 的一个办法 问题: 执行 $ sudo docker run hello-world 时出现: ...

  4. UVa 11609 组队(快速幂)

    https://vjudge.net/problem/UVA-11609 题意: 有n个人,选一个或多个人参加比赛,其中一名当队长,有多少种方案?如果参赛者完全相同,但队长不同,算作不同的方案. 思路 ...

  5. 用 Rprof 进行性能分析

    R 提供了内置函数 Rprof( ) 对代码的性能进行分析.在分析过程中,会有一个抽样程序,并且是和后续代码一起运行的,直到分析结束.默认情况下,抽样程序基本上每隔20 毫秒就会记录一下当前 R 在运 ...

  6. thinkphp3.2笔记(2)调试模式,配置项C,创建模块, 四种URL模式,URL生成,跳转

    一.调试模式 TP的调试模式其实就控制了TP关于配置信息以及函数的缓存功能 如果开启了调试模式,每次访问项目,Tp都会去加载最新的配置以及函数信息. 如果关闭了调试模式,当tp第一次访问时会降配置以及 ...

  7. Django框架(上传Excel文件并读取)

    博主今天整理下Django框架中上传Excel文件并读取 博主是要在管理平台中新增用例的维护功能,想着通过上传Excel文件来展示用例,下面是项目的路径图: 首先先建数据库模型 model.py 可以 ...

  8. 将Excel的数据更新至SqlServer

    update P_Dic_Region set F_Long=a.F_Long,F_Lat=a.F_Lat from( select * from OPENDATASOURCE( 'Microsoft ...

  9. VGG16提取图像特征 (torch7)

    VGG16提取图像特征 (torch7) VGG16 loadcaffe torch7 下载pretrained model,保存到当前目录下 th> caffemodel_url = 'htt ...

  10. Invalid bound statement (not found)错误的可能原因

    其他原因导致此问题解决参考: 1.检查xml文件所在package名称是否和Mapper interface所在的包名 <mapper namespace="me.tspace.pm. ...