title: How to compile OpenCV3 using MinGW
body: <p>I am trying to compile <code>OpenCV3</code> and put it into Qt project because Qt officially provides <code>MinGW</code> Version, so I didn't use <code>MinGW-w64</code>.</p>
  
  <p>I enabled <code>ENABLE_CXX11</code> and disabled <code>ENABLE_PRECOMPILED_HEADERS</code> in CMake.</p>
  
  <p>Now the problem is <code>MinGW</code> does not contain <code>std::thread</code>. </p>
  
  <p>I know the <code>mingw-std-threads</code> lib can fix it. but I don't want to modify OpenCV source code. Is there any other way to adding c++ thread feature to <code>MinGW</code>? or tell OpenCV using <code>pthread</code> by <code>CMake</code>?</p>
  
  <p>BTW. I don't want use <code>Qt's MinGW</code> because I think using official <code>MinGW</code> to compile the lib shall be used in any version of Qt.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>In OpenCV <code>detection_based_tracker.cpp</code>, there is a <code>CV_CXX11</code> Marco choice to the using <code>std thread</code> or the <code>pthread</code>. But I didn't see anywhere <code>define CV_CXX11</code>.</p>
  
  <p>Is part of <code>detection_based_tracker.cpp</code> code:</p>
  
  <pre><code>#ifdef CV_CXX11
  #define USE_STD_THREADS
  #endif
  
  #ifdef USE_STD_THREADS
  #include &lt;thread&gt;
  #include &lt;mutex&gt;
  #include &lt;condition_variable&gt;
  #else //USE_STD_THREADS
  #include &lt;pthread.h&gt;
  #endif //USE_STD_THREADS
  </code></pre>
  
  <p>My environment:</p>
  
  <pre><code>windows 7 64bit
  cmake-3.10.1-win64-x64
  opencv-3.4.0
  gcc 6.3
  </code></pre>
  
  <p>What I tried:</p>
  
  <ol>
  <li>install CMake and MinGW</li>
  <li>disable <code>ENABLE_PRECOMPILED_HEADERS</code> in <code>CMake-gui</code></li>
  <li>comment <code>#define USE_STD_THREADS</code> in <code>detection_based_tracker.cpp</code> line 48</li>
  <li>configure and generate Makefile</li>
  <li>Run <code>mingw32-make</code> </li>
  </ol>
  
  <p>it's successfully compiled, but I have to modify OpenCV source code.</p>