Using visual studio 2010 and Matlab R2012a (32 -bit) and on a 32bit platform:
I want just to call a function from matlab in c++ using matlab engine. I get the matlab function output in a separate solution and it works well; I did the same setting in my main project such as setting the additional include path and additional library path and also I set the linker inputs. also I set the path environment variable for operating system. but it does not work! my code is :
double* P::FindingCameraPosition()
{
double Result[6];
Engine *ep;
if (!(ep = engOpen("")))
{
cout<<"Error in starting matlab engine!"<<endl;
}
double *cresult;
mxArray *mresult;
mresult = mxCreateDoubleMatrix(1,1,mxREAL);
engEvalString(ep , "z=Position()");
mresult = engGetVariable(ep,"z");
cresult = mxGetPr(mresult);
for(int i = 0; i < 6; i++)
{
Result[i] = cresult[i];
}
engClose(ep);
return Result;
}
I see these errors :
error LNK2001: unresolved external symbol _engClose
error LNK2001: unresolved external symbol _engEvalString
error LNK2001: unresolved external symbol _engGetVariable
error LNK2001: unresolved external symbol _engOpen
error LNK2001: unresolved external symbol _mxCreateDoubleMatrix_730
error LNK2001: unresolved external symbol _mxGetPr
I read this and it did not help me at all; all of the others who faced these errors, missed the step of adding libraries to the linker input; but I set it and checked it several times;
why it is work as a separate project and does not work in another solution? I got confused! I am using the openGL32 in my project. so I guess that using opengl and matlab engine has not compatibality with each other;
Can you suggest me the ways you tried before?
thank you so much!