Vote count:
0
I'm wondering why the code I'm using with a compiled Matlab library crashes when a common language runtime is not selected. For a minimal example, I've tried compiling the following Matlab function into a shared library:
function [volOut, volAvg]=testVarPass(volIn)
volOut=double(volIn);
volAvg=mean(volOut(:));
end
using the following call to mcc: mcc -B csharedlib:mylib testVarPass.m
Next, I've set up a Visual Studios 2010 Console Project.
#include "stdafx.h"
#include "matrix.h"
#include "mylib.h"
int _tmain(int argc, _TCHAR* argv[])
{
mxArray *vol_in;
mxArray *vol_out;
mxArray *vol_avg;
mwSize dim_list[3];
double *vol_avg_ptr;
dim_list[0]=10;
dim_list[1]=10;
dim_list[2]=10;
if( !mclInitializeApplication(NULL,0) ) { //initialize Matlab Compiler Runtime
return -1;
}
if (!mylibInitialize()) //initialize library
{
return -2;
}
vol_in=mxCreateNumericArray(3,dim_list, mxINT16_CLASS, mxREAL); //make a sample 3d array
mlfTestVarPass(2, &vol_out, &vol_avg, vol_in); //crashes here
vol_avg_ptr=mxGetPr(vol_avg);
/* Call the MCR and library termination functions */
mylibTerminate();
mclTerminateApplication();
return 0;
}
If I build the project with Common Language Runtime Support set to: /clr...everything works fine. If I build the project with Common Language Runtime Support set to: nothing...first, the debugger vomits many exceptions when mylibInitialize is called. The most common are: varflowFailed, tffFailed, CryptoPP, jitCgFailed, and xsd_binder::MalformedDocumentError. Second, the mlfTestVarPass call crashes with an access violation.
I, and a programming I'm working with, are wondering why.
Other Information: Windows 7 Visual Studio 2010, SP1 Windows SDK 7.1 Matlab 2013b
Aucun commentaire:
Enregistrer un commentaire