我想要做的是将MATLAB-Compiler dll / lib集成到一个新的c ++项目中。
我遵循了这个指令:qazxsw poi哪个接缝工作正常(没有构建错误和intellisense工作正常,所以它接缝所有必需的信息都在那里)。
我正在使用一个非常简单的matlab代码/函数进行测试:
How do I integrate my C++ shared Library generated from MATLAB
以及matlab函数的“默认”c ++代码:
function output = extest( arg1,arg2 )
output = arg1+arg2;
end
在调试器尝试运行#include "extest.h"
#include <cstdlib>
#include <stdio.h>
int main(int argc, char** argv){
mclmcrInitialize();
if (!mclInitializeApplication(NULL,0)){
std::cerr << "could not initialize the application properly" << std::endl;
return -1;
}
if(!extestInitialize()){
std::cerr << "could not initialize the library properly" << std::endl;
return -1;
}
else{
try{
//code itself (not jet reached therefore removed)
}catch(const mwException& e){
std::cerr << e.what() << std::endl;
return -2;
}
catch(...){
std::cerr << "Unexpected error thrown" << std::endl;
return -3;
}
extestTerminate();
}
mclTerminateApplication();
return 0;
}
行之后片刻之后,会抛出以下错误。
在DllTestingCpp.exe中0x000002BF72E0EE55处抛出异常:0xC0000005:访问冲突读取位置0x0000000000000008。
if(!extestInitialize())
我可以点击视觉工作室按钮,它继续后,让我们说20倍点击它。通过continue >
启动代码(无需调试)一切正常。
任何想法为什么会在调试模式下发生?或者更好的我如何摆脱这个错误?
PS:ctrl + F5
是我的lib名称,使用Matlab R2017a 64bit和Visual Studio 2017(用x64调试),