1

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!

Community
  • 1
  • 1
  • Please check if everything is set to 32-bit, especially project which you build in Visual Studio (Active Solution Platform in Project Properties -> Configuration Manager). – durasm Apr 10 '14 at 06:59
  • Check also [link](http://stackoverflow.com/questions/8800439/problems-including-matlab-engine-h-for-c-code?rq=1). – durasm Apr 10 '14 at 07:01
  • thank you so much ;) I checked its running on Win32 and linker is set for all configuration. but this errors does not solve :( – user3159964 Apr 11 '14 at 14:39
  • I checked your link before but it did not help me ... – user3159964 Apr 11 '14 at 14:41

0 Answers0