Invalid Address specified to RtlValidateHeap

http://blog.csdn.net/bao_qibiao/article/details/5257150#

一.首先是”Invalid Address specified to RtlValidateHeap

找到了这篇文章:http://hi.baidu.com/umu618/blog/item/d4e8242e424e3e564fc226d3.html

“一个可能的原因:在不同模块(工程)之间传递 C++ 类,而这两个模块用了不同的运行时库(Runtime Library)设置。例如:EXE 模块调用 DLL 模块里传递 C++ 类的函数,但 DLL 模块使用静态链接(Release 是 Multi-threaded (/MT) 、Debug 是 Multi-threaded Debug (/MTd) )方式编译,而 EXE 模块使用动态链接(Release 是 Multi-threaded DLL (/MD) 、Debug 是 Multi-threaded Debug DLL (/MDd) )方式编译。

  可以对比这两个模块的工程属性 - C/C++ - Code Generation - Runtime Library ,看看设置是否一样,如果不一样要改成一样的。“

二.把我的exe工程属性改成和dll一样的Multi-threaded Debug DLL (/MDd)后,

出现nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv

找到这篇文章:http://blog.csdn.net/pbdwadr/archive/2007/09/07/1775675.aspx,如下:

1. 【错误提示】: libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
【说 明】: Windows项目要使用Windows子系统, 而不是Console
【解决方法】:[Project] --> [Settings] --> 选择"Link"属性页,
在Project Options中将/subsystem:console改成/subsystem:windows


2. 【错误提示】:LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
【说 明】:控制台项目要使用Console子系统, 而不是Windows
【解决方法】:[Project] --> [Settings] --> 选择"Link"属性页,
在Project Options中将/subsystem:windows改成/subsystem:console


3. 【错误提示】:msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16
【说 明】:通常, MFC项目的程序入口函数是WinMain, 如果编译项目的Unicode版本, 程序入
口必须改为wWinMainCRTStartup, 所以需要重新设置程序入口
【解决方法】:[Project] --> [Settings] --> 选择"C/C++"属性页,
在Category中选择Output,
再在Entry-point symbol中填入wWinMainCRTStartup, 即可

4. 【错误提示】: nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex

【说 明】:这是因为MFC要使用多线程时库
【解决方法】:[Project] --> [Settings] --> 选择"C/C++"属性页,
在Category中选择Code Generation,
再在Use run-time library中选择Debug Multithreaded或者multithreaded
其中,
Single-Threaded 单线程静态链接库(release版本)
Multithreaded 多线程静态链接库(release版本)
multithreaded DLL 多线程动态链接库(release版本)
Debug Single-Threaded 单线程静态链接库(debug版本)
Debug Multithreaded 多线程静态链接库(debug版本)
Debug Multithreaded DLL 多线程动态链接库(debug版本)
单线程: 不需要多线程调用时, 多用在DOS环境下
多线程: 可以并发运行
静态库: 直接将库与程序Link, 可以脱离MFC库运行
动态库: 需要相应的DLL动态库, 程序才能运行
release版本: 正式发布时使用
debug版本: 调试阶段使用

5. 【错误提示】: Compiling... ,Error spawning cl.exe
【说 明】:这个问题很多情况下是由于路径设置的问题引起的,“CL.exe”是VC使用真正
的编译器(编译程序),其路径在“VC根目录/VC98/Bin”下面,你可以到相
应的路径下找到这个应用程序。
【解决方法】:“TOOLS(工具)”—>“Option(选择)”—>“Directories(目录)”
重新设置“Excutable Fils、Include Files、Library Files、Source Files”的路径。
6. 【错误提示】: nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
【说 明】:
【解决方法】:在Preprocessor中定义_AFXDLL
7. 【错误提示】:fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
【说 明】:
【解决方法】:/C++->Code Generation->Multithread DLL (即实现/MD选项)
按照方法6解决

三.一个相关的问题 nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in utility.obj
几种解决方法:(以前的笔记,忘记其中的一些原帖了)
1.

你只需要在工程设置里面,把

WIN32,NDEBUG,_WINDOWS,_MBCS,_USRDLL,MSGBOX_EXPORTS,_WINDLL,_AFXDLL

中的_USRDLL,删除,就可以正确编译了

另一种描述

nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined
google半天没搞定
只好自己搞,最后将工程里面的_USRDLL宏定义去除,瞎猫碰到死耗子了,好了。

在afx.h中发现一段代码
#ifdef _USRDLL
#pragma comment(linker, "/include:__afxForceUSRDLL")
#endif
就我现在的水平,没看懂,留着以后慢慢看吧,呵呵!

2.Linker Tools Error LNK2005 symbol already defined in object
The given symbol, displayed in its decorated form, was multiply defined.

Tips
One of the following may be a cause:
The most common cause of this error is accidentally linking with both the single-threaded and multithreaded libraries. Ensure that the application project file includes only the appropriate libraries and that any third-party libraries have appropriately created single-threaded or multithreaded versions.

The given symbol was a packaged function (created by compiling with /Gy) and was included in more than one file but was changed between compilations. Recompile all files that include the symbol.
The given symbol was defined differently in two member objects in different libraries, and both member objects were used.

An absolute was defined twice, with a different value in each definition.

Linker Tools Error LNK1169 one or more multiply defined symbols found

The build failed due to multiple definitions of one or more symbols. This error is preceded by error LNK2005.

The /FORCE or /FORCE:MULTIPLE option overrides this error.

4.官方解决方案 :http://support.microsoft.com/kb/148652/zh-cn

在 Visual C++ 中以错误的顺序链接 CRT 库和 MFC 库时出现 LNK2005 错误

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值