title: Reading Mat File In C
body: <p>I am new to Visual Studio and C/C++ ...though i have worked in MATLAB ...</p>
  
  <p>i am trying to load mat file using MAT API as given in MATLAB help  but even for the simple code given below it is compiling but the solution is not building  and its giving 4 errors all of same sort.. i have included all lib and header files as additional lib and include folders...</p>
  
  <p>need serios help... thanks</p>
  
  <p>Error   1   error LNK2019: unresolved external symbol _mxFree referenced in function _main  test2.obj   test2</p>
  
  <p>Error   2   error LNK2019: unresolved external symbol _matGetVariable referenced in function _main  test2.obj   test2</p>
  
  <p>the rest two errors are also of the other MAT-API...</p>
  
  <pre><code>enter code here
  
  #include &lt;mat.h&gt;
  #include &lt;stdio.h&gt;
  void main()
  {
  
  MATFile *pmat;
  const char **dir;
  int     ndir;      
  int     i;
  mxArray *pfp;
  
  pmat=matOpen("data3.mat","r");
  
  
   /* get directory of MAT-file */
   dir = (const char **)matGetDir(pmat, &amp;ndir);
  
  
  printf("Directory of %s:\n","data3.mat");
  for (i=0; i &lt; ndir; i++)
  {
      printf("%s\n",dir[i]);
  }   
  
  //to get the pointer of data from file  
   pfp=matGetVariable(pmat, "fp");
   mxFree(dir);
  
   }  
  </code></pre>