title: unresolved external symbol - Error using Matlab API
body: <p>I'm trying to read a .mat-file in C++ with MSVS 2008 but when building a simple program I get the following error:</p>
  
  <p>1>ex3.obj : error LNK2019: unresolved external symbol _matClose referenced in function _main
  1>ex3.obj : error LNK2019: unresolved external symbol _matOpen referenced in function _main</p>
  
  <p>I've researched Google as well and it seems that the compiler can't link to the libraries needed for using this functions (matOpen and matClose). I never used an external library before but I tried everything I found in Google to add the Matlab libraries. I did the following:</p>
  
  <p>TOOLS --> Options --> Projects and Solutions --> VC++ Directories --> Show directories for: include files --> then I added the path of the matlab include directory --> C:\Program Files\MATLAB\extern\include</p>
  
  <p>I did the same with the library files: C:\Program Files\MATLAB\extern\lib\win64\microsoft</p>
  
  <p>I also did that for the project:
  Right click on the project --> Properties --> Configuration Properties --> C/C++ --> General --> Additional Include Directories --> and added "C:\Program Files\MATLAB\extern\include\win64"</p>
  
  <p>Then I did the same at Linker --> General --> Additional Library Directories --> and added "C:\Program Files\MATLAB\extern\lib\win64\microsoft"</p>
  
  <p>So I really don't know where the problem is. Here is the source code I'm trying to build:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;mat.h&gt;
  
  int main(int argc, char *argv[])
  {
  const char *file = "mozart_part1.mat";
  MATFile *pmat;
  
  pmat = matOpen(file, "r");
  if(pmat == NULL)
  {
      std::cout &lt;&lt; "Error: could not open MAT-file!";
      return(1);
  }
  matClose(pmat);
  }
  </code></pre>
  
  <p>Can you see or guess any mistakes I made</p>