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