title: Runtime libraries and Static libraries of OpenCV
body: <p>I have posted two question before about static and dynamic libaries and got satisfactory responses. But still there are some missing links. </p>
  
  <p>I am able to solve my problem but I did not understand the complete concept.</p>
  
  <p><strong>Concept to be understand:</strong> Through the response in my previous <a href="https://stackoverflow.com/questions/32562242/static-and-dynamic-linking-in-visual-studio">question </a>, I realized that I do not have static libraries of OpenCV, so I installed them. Now, I have static libraries of OpenCV in Windows 7. </p>
  
  <p>I made a simple program as given below to test the functionalityof static libraries of OpenCV.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "opencv\highgui.h"
  #include "opencv2\core\core.hpp"
  #include "opencv2\imgproc\imgproc.hpp"
  
  int main()
  {
      cv::Mat image(100, 500, CV_8SC3, Scalar(0,0,255));
      std::cout &lt;&lt; "\nstatic Libs test"&lt;&lt;std::endl;
      return 0;
  }
  </code></pre>
  
  <p>For the linking of above code, I have used the static libraries of OpenCV.</p>
  
  <p><strong>Real Question:</strong> The above code gets compiled, linked and run without any issue if I choose <code>Multi-threaded Debug (/MTd)</code> runtime libraries in Visual Studio. But if I choose <code>Multi-threaded Debug DLL (/MDd)</code> runtime libraries then, there are a lot of erros which look like following (I have not included all the errors): </p>
  
  <pre><code>Error   1   error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in Source.obj 
  Error   22  error LNK2005: "public: __cdecl std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QEAA@XZ) already defined in opencv_core2411d.lib(alloc.obj)
  </code></pre>
  
  <p>I just want to understand the reason of such conflict between the DLL runtime libraries of C++ and Static libraries of OpenCV. After choosing <code>Multi-threaded Debug (/MTd)</code>, are the C++ libraries are also getting linked statically?</p>
  
  <p>And lastly, which runtime library option should be selected if I want to link few openCV libraries statically and few dynamically (situation might seem awkward but just asking)?</p>