title: Linker Error (MEX could not find the OpenCV library)
body: <p>I'm using MATLAB R2013a x64 and Win7 x64. I installed OpenCV 2.4.7.2 to the path (C:\opencv). Previous compile errors with <code>round</code> are solved, but now there is a linking error.</p>
  
  <p>MEX command output:</p>
  
  <pre class="lang-none prettyprint-override"><code>&gt;&gt; mex -LC:\opencv\build\x64\vc11\lib -IC:\opencv\build\include\opencv -lcv -lcxcore me_HaarDetectOpenCV.cpp
  
  Warning: MEX could not find the library "cv" specified with -l option. 
           MEX looked for a file with one of the names: 
                 cv.lib 
                 libcv.lib 
           MEX looked for the library in the following directories: 
                 D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\LIB\amd64 
                 D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\LIB\amd64 
                 C:\Program Files (x86)\Windows Kits\8.0\lib\win8\um\x64 
                 D:\Program Files\MATLAB\R2013a\extern\lib\win64 
                 D:\Program Files\MATLAB\R2013a\extern\lib\win64\microsoft 
                 C:\opencv\build\x64\vc11\lib 
  
  Warning: MEX could not find the library "cxcore" specified with -l option. 
           MEX looked for a file with one of the names: 
                 cxcore.lib 
                 libcxcore.lib 
           MEX looked for the library in the following directories: 
                 D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\LIB\amd64 
                 D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\LIB\amd64 
                 C:\Program Files (x86)\Windows Kits\8.0\lib\win8\um\x64 
                 D:\Program Files\MATLAB\R2013a\extern\lib\win64 
                 D:\Program Files\MATLAB\R2013a\extern\lib\win64\microsoft 
                 C:\opencv\build\x64\vc11\lib 
  
       Creating library C:\Users\AsUs\AppData\Local\Temp\mex_47j5SQ\templib.x and object C:\Users\AsUs\AppData\Local\Temp\mex_47j5SQ\templib.exp 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvCreateImage referenced in function mexFunction 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvReleaseImage referenced in function mexFunction 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvCreateMemStorage referenced in function mexFunction 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvReleaseMemStorage referenced in function mexFunction 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvGetSeqElem referenced in function mexFunction 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvLoad referenced in function mexFunction 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvEqualizeHist referenced in function mexFunction 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvReleaseHaarClassifierCascade referenced in function mexFunction 
    me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvHaarDetectObjects referenced in function mexFunction 
    me_HaarDetectOpenCV.mexw64 : fatal error LNK1120: 9 unresolved externals 
  
      D:\PROGRA~2\MATLAB\R2013A\BIN\MEX.PL: Error: Link of 'me_HaarDetectOpenCV.mexw64' failed. 
  
  Error using mex (line 206)
  Unable to complete successfully. 
  &gt;&gt;
  </code></pre>
  
  <p>How do I fix the error and compile (create the MEX file <code>me_HaarDetectOpenCV.mexw64</code>)?</p>
  
  <hr>
  
  <p>i'm edit <a href="http://pastebin.com/r36FXZDk" rel="nofollow"><code>me_HaarDetectOpenCV.Cpp</code></a> and fix error .</p>
  
  <pre><code>#include "D:\Program Files\MATLAB\R2013a\extern\include\mex.h"
  #include "C:\opencv\build\include\opencv\cv.h" 
  #include "C:\opencv\build\include\opencv\highgui.h"
  #include "C:\opencv\build\include\opencv\cxcore.h"
  </code></pre>
  
  <p>MEX command output:</p>
  
  <pre><code>&gt;&gt; mex me_HaarDetectOpenCV.cpp
     Creating library C:\Users\AsUs\AppData\Local\Temp\mex_7BQNq1\templib.x and object C:\Users\AsUs\AppData\Local\Temp\mex_7BQNq1\templib.exp 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvReleaseMemStorage referenced in function mexFunction 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvReleaseHaarClassifierCascade referenced in function mexFunction 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvReleaseImage referenced in function mexFunction 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvGetSeqElem referenced in function mexFunction 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvHaarDetectObjects referenced in function mexFunction 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvEqualizeHist referenced in function mexFunction 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvCreateMemStorage referenced in function mexFunction 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvCreateImage referenced in function mexFunction 
  me_HaarDetectOpenCV.obj : error LNK2019: unresolved external symbol cvLoad referenced in function mexFunction 
  me_HaarDetectOpenCV.mexw64 : fatal error LNK1120: 9 unresolved externals 
  
    D:\PROGRA~2\MATLAB\R2013A\BIN\MEX.PL: Error: Link of 'me_HaarDetectOpenCV.mexw64' failed. 
  
  Error using mex (line 206)
  Unable to complete successfully. 
  </code></pre>