c++中Debug与Release版本的库(或者程序)混合使用的问题分析
Debug与Release版本的库正常是不能混用的,混用之后,大概率会出现堆异常或者其它未知错误,具体原因也不是很清楚,查阅资料也是了解了大致情况,没有更深入的剖析,比较了解的可以推荐一下,下面这段话是网上查阅的。
·
Debug与Release版本的库正常是不能混用的,混用之后,大概率会出现堆异常或者其它未知错误,具体原因也不是很清楚,查阅资料也是了解了大致情况,没有更深入的剖析,比较了解的可以推荐一下,下面这段话是网上查阅的
If you have an EXE and a DLL.
When your exe APP was built Debug Mode, your Dll must be Debug mode.
When your exe APP was built Release Mode, your Dll must be Release mode.
If exe is Release Mode and Dll is Debug Mode, Error.
If exe is Debug Mode and Dll is Release Mode, Error.
-------------------------------- Why? --------------------------------
Looks like you have a problem with memory allocation.
When an application is built in debug mode it does not allocate memory from the same heap as it does in release mode.(have a look to the definition of new and delete operator, and also to malloc (in afxmem.h ? (not sure just grep it))
Thus, when you get some memory from your debug app and give this memory to your release dll for processing and FREEING,you get an error since the realase dll tries to free it from the wrong heap. So always use your app and dll in the same mode.
At least, do not try to free memory allocation in one mode in the other mode.
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)