MATLAB: Problem using Intel MKL with MEX

mex

Dear All,
Is it possible to use Intel MKL 10.3 in MEX? I am having problem in using MKL 10.3 along with MEX. I have no problem in compiling and linking the source code. But MATLAB crashes with no helpful message when I run the executable. The same code works perfectly in Visual Studio C++. Is there any conflict for using MKL in MALTAB?
Thanks

Best Answer

Your posted code looks erroneous because in the success case it will naturally drop through the FAILURE label and do the free stuff again. Maybe you want something like this instead:
if (stat!=0) {
printf("\nFAILED to compute \n");
}
MKL_FreeBuffers();
free( dpar );
free( f );