我的程序结构是一个EXE工程和一个DLL工程,用degub编译两个工程,OK,运行OK。可是当用release编译,ok,运行出错,错在调用DLL的一个export函数:
extern "C" __declspec(dllexport) signed int TestFlashStart(const unsigned int nPortCOM,
const unsigned int nCOMBaudrate,
const unsigned int nCOMType,
const float fOverspeed,
const char* PathFileName,
const unsigned int nProcessType,
const unsigned int nSoftwareSource,
const char* BtAddrRep,
const bool bStartupDetection,
const char* PFCode)
更改了release的编译参数,使之可以F5调试,在调用这个函数之前一切正常,可是运行到这个函数就出现:
First-chance exception in Interface.exe (MSVCP60.DLL): 0xC0000005: Access Violation.
而且无法F11单步函数的执行,直接出错,不知道问题在哪里。
而debug模式下跟踪,没有发现问题。各位有没有类似的经历,可否劳烦分享一下经验,万分感谢!!
extern "C" __declspec(dllexport) signed int TestFlashStart(const unsigned int nPortCOM,
const unsigned int nCOMBaudrate,
const unsigned int nCOMType,
const float fOverspeed,
const char* PathFileName,
const unsigned int nProcessType,
const unsigned int nSoftwareSource,
const char* BtAddrRep,
const bool bStartupDetection,
const char* PFCode)
更改了release的编译参数,使之可以F5调试,在调用这个函数之前一切正常,可是运行到这个函数就出现:
First-chance exception in Interface.exe (MSVCP60.DLL): 0xC0000005: Access Violation.
而且无法F11单步函数的执行,直接出错,不知道问题在哪里。
而debug模式下跟踪,没有发现问题。各位有没有类似的经历,可否劳烦分享一下经验,万分感谢!!
http://read.newbooks.com.cn/info/172174.html
错误的函数就是这个TestFlashStart(), 断点就设置在这个函数上,可以断,然后单步执行(F11)马上出错,根本看不到执行了什么,(这些都是release模式下的debug,我改了编译参数,让编译器为release模式生成调试符号表,是不是release模式下看到的不全是正在执行的代码?)
保证每个变了定义后都初始化过!
http://www.cnblogs.com/chenhs/archive/2009/04/10/1432816.html
http://www.cnblogs.com/ubunoon/archive/2008/07/25/1251147.html
To set the properties "Use MFC In A Shared DLL " 另外,在网上也发现另外一篇,console方面的, 解决办法:使用c runtime library的动态链接版本(在你的console工程中设置忽略所有的默认链接库,然后链接到msvcrt.lib就可以了)(具体地址:http://www.poptool.net/software/p606/A60674501.shtml)
------------------------------------------------------
我的exe工程和DLL工程都使用“USE MFC In a static DLL”解决问题,虽然不知道为什么shared DLL在我这里还是出错
谢谢!!