Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation Error while running OpenCV 3.3.1 src code with MinGW and Cmake. #10272

Closed
tenderZeitGeist opened this issue Dec 9, 2017 · 9 comments

Comments

@tenderZeitGeist
Copy link

tenderZeitGeist commented Dec 9, 2017

Hi there,
I am trying to compile OpenCV for my systems with MinGW 7.2.0., configured as win32 and CMake 3.10. But since half a week I got this error and I tried a lot, googled a lot and now kinda at the wit's end. Most solutions are seem so simple, yet this specify problem got questioned very rarely and there is no real solution to it, which is why I am raising this issue.

Thanks in advance!

Here is the log from the compiling process:

E:\Application\opencv\mingw-build>mingw32-make
[  0%] Built target gen-pkgconfig
[  2%] Built target zlib
[  6%] Built target libtiff
[ 10%] Built target libjpeg
[ 19%] Built target libwebp
[ 22%] Built target libjasper
[ 23%] Built target libpng
[ 29%] Built target IlmImf
[ 35%] Built target libprotobuf
[ 40%] Built target opencv_core
[ 46%] Built target opencv_imgproc
[ 48%] Built target opencv_imgcodecs
[ 49%] Built target opencv_videoio
[ 49%] Built target opencv_highgui
[ 50%] Built target opencv_ts
[ 52%] Built target opencv_test_core
[ 55%] Built target opencv_perf_core
[ 55%] Built target opencv_flann
[ 55%] Built target opencv_test_flann
[ 59%] Built target opencv_test_imgproc
[ 62%] Built target opencv_perf_imgproc
[ 64%] Built target opencv_ml
[ 65%] Built target opencv_test_ml
[ 65%] Building CXX object modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:175:14: error: 'thread' in namespace 'std' does not name a type
         std::thread second_workthread;
              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:176:14: error: 'mutex' in namespace 'std' does not name a type
         std::mutex mtx;
              ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:177:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorRun;
              ^~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:178:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorThreadStartStop;
              ^~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::setParameters(const cv::DetectionBasedTracker::Parameters&)':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:35: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                   ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:35: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:51: error: 'mtx' was not declared in this scope
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                                   ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::init()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:35: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                   ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:35: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:51: error: 'mtx' was not declared in this scope
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                                   ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:164:13: error: 'objectDetectorThreadStartStop' was not declared in this scope
             objectDetectorThreadStartStop.notify_one();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:164:13: note: suggested alternative: 'timeWhenDetectingThreadStartedWork'
             objectDetectorThreadStartStop.notify_one();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             timeWhenDetectingThreadStartedWork
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In destructor 'virtual cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:254:5: error: 'second_workthread' was not declared in this scope
     second_workthread.join();
     ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::run()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:261:27: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                           ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:261:27: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:261:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:261:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:275:5: error: 'second_workthread' was not declared in this scope
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
     ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:275:30: error: 'thread' is not a member of 'std'
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
                              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:275:30: note: suggested alternative: 'tera'
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
                              ^~~~~~
                              tera
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:276:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:276:5: note: suggested alternative: 'timeWhenDetectingThreadStartedWork'
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     timeWhenDetectingThreadStartedWork
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:317:27: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                           ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:317:27: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:317:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:317:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:323:9: error: 'objectDetectorThreadStartStop' was not declared in this scope
         objectDetectorThreadStartStop.notify_one();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:323:9: note: suggested alternative: 'timeWhenDetectingThreadStartedWork'
         objectDetectorThreadStartStop.notify_one();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         timeWhenDetectingThreadStartedWork
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:330:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.wait(mtx_lock);
         ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:340:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:357:22: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
             mtx_lock.lock();
                      ^~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:364:26: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
                 mtx_lock.unlock();
                          ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:372:13: error: 'objectDetectorRun' was not declared in this scope
             objectDetectorRun.wait(mtx_lock);
             ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:380:22: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
             mtx_lock.unlock();
                      ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:431:18: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.lock();
                  ^~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:447:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.unlock();
                  ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::stop()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:462:25: error: 'mutex' is not a member of 'std'
   std::unique_lock<std::mutex> mtx_lock(mtx);
                         ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:462:25: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:462:30: error: template argument 1 is invalid
   std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:462:41: error: 'mtx' was not declared in this scope
   std::unique_lock<std::mutex> mtx_lock(mtx);
                                         ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:468:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.unlock();
                  ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:479:5: error: 'objectDetectorRun' was not declared in this scope
     objectDetectorRun.notify_one();
     ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:480:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:480:5: note: suggested alternative: 'timeWhenDetectingThreadStartedWork'
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     timeWhenDetectingThreadStartedWork
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:482:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:495:27: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                           ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:495:27: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:495:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:495:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:512:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const cv::Mat&, std::vector<cv::Rect_<int> >&)':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:533:27: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                           ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:533:27: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:533:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:533:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:566:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.notify_one();
         ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:573:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
mingw32-make[2]: *** [modules\objdetect\CMakeFiles\opencv_objdetect.dir\build.make:119: modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2118: modules/objdetect/CMakeFiles/opencv_objdetect.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2

And here is my Cmake File:

General configuration for OpenCV 3.3.1-dev =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2017-12-09T13:12:39Z
    Host:                        Windows 10.0.16299 AMD64
    CMake:                       3.10.0
    CMake generator:             MinGW Makefiles
    CMake build tool:            E:/Application/mingw-w64/mingw64/bin/mingw32-make.exe
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2
      SSE4_1 (3 files):          + SSSE3 SSE4_1
      SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (2 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (9 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

  C/C++:
    Built as dynamic libs?:      YES
    C++11:                       YES
    C++ Compiler:                E:/Application/mingw-w64/mingw64/bin/g++.exe  (ver 7.2.0)
    C++ flags (Release):         -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  E:/Application/mingw-w64/mingw64/bin/gcc.exe
    C flags (Release):           -std=gnu++11 ${CMAKE_CXX_FLAGS}   -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -std=gnu++11 ${CMAKE_CXX_FLAGS}   -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wno-implicit-fallthrough -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--gc-sections  
    Linker flags (Debug):        -Wl,--gc-sections  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo shape stitching superres ts video videoio videostab
    Disabled:                    js world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

  Windows RT support:            NO

  GUI: 
    Win32 UI:                    YES
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.2.8)
    JPEG:                        build (ver 90)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         build (ver 1.6.24)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)

  Video I/O:
    Video for Windows:           YES
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (ver 57.89.100)
      avformat:                  YES (ver 57.71.100)
      avutil:                    YES (ver 55.58.100)
      swscale:                   YES (ver 4.6.100)
      avresample:                YES (ver 3.5.0)
    GStreamer:                   NO
    DirectShow:                  YES

  Parallel framework:            none

  Trace:                         YES (built-in)

  Other third-party libraries:
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO

  NVIDIA CUDA:                   NO

  OpenCL:                        YES (no extra features)
    Include path:                E:/Application/opencv/opencv_source/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            NO

  Java:
    ant:                         NO
    JNI:                         E:/Application/Java/include E:/Application/Java/include/win32 E:/Application/Java/include
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        NO

  Install to:                    E:/Application/opencv/mingw-build/install
-----------------------------------------------------------------
@alalek
Copy link
Member

alalek commented Dec 9, 2017

C flags (Release): -std=gnu++11 ${CMAKE_CXX_FLAGS}

Looks like compiler flags are misused:

  • c++ flag for C compilation
  • non-expanded variable

Clear CMake cache (clear build directory) and try again.

@tenderZeitGeist
Copy link
Author

tenderZeitGeist commented Dec 9, 2017

Ah, clearly my fault there, I see. But after making sure, it was correct, regenerating the project with Cmake and another compiling attempt, I am still stuck at the detection_base_tracker.cpp.
What do you mean with "non-expanded variable"? Basically, I am leaving the most on default, except for precompiled headers and specify the compiler onto CXX_11, so I am quite a beginner, when it come to such things regarding C++, hence the question.

@alalek
Copy link
Member

alalek commented Dec 9, 2017

${CMAKE_CXX_FLAGS} is non-expanded variable. It should not be there.

make VERBOSE=1 shows final compiler command-line options.

@tenderZeitGeist
Copy link
Author

tenderZeitGeist commented Dec 10, 2017

Alright, so I redone it as you told me, but the error still occurs. Here is the log from the compilation attempt.

[ 65%] Building CXX object modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj
cd /d E:\Application\opencv\mingw-build\modules\objdetect && E:\Application\mingw-w64\mingw64\bin\g++.exe -DCVAPI_EXPORTS -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS @CMakeFiles/opencv_objdetect.dir/includes_CXX.rsp -std=c++11 -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG -o CMakeFiles\opencv_objdetect.dir\src\detection_based_tracker.cpp.obj -c E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp

E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:175:14: error: 'thread' in namespace 'std' does not name a type
         std::thread second_workthread;
              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:176:14: error: 'mutex' in namespace 'std' does not name a type
         std::mutex mtx;
              ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:177:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorRun;
              ^~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:178:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorThreadStartStop;
              ^~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::setParameters(const cv::DetectionBasedTracker::Parameters&)':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:35: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                   ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:35: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:51: error: 'mtx' was not declared in this scope
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                                   ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:143:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::init()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:35: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                   ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:35: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:51: error: 'mtx' was not declared in this scope
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                                   ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:164:13: error: 'objectDetectorThreadStartStop' was not declared in this scope
             objectDetectorThreadStartStop.notify_one();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:164:13: note: suggested alternative: 'timeWhenDetectingThreadStartedWork'
             objectDetectorThreadStartStop.notify_one();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             timeWhenDetectingThreadStartedWork
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:156:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In destructor 'virtual cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:254:5: error: 'second_workthread' was not declared in this scope
     second_workthread.join();
     ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::run()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:261:27: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                           ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:261:27: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:261:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:261:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:275:5: error: 'second_workthread' was not declared in this scope
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
     ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:275:30: error: 'thread' is not a member of 'std'
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
                              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:275:30: note: suggested alternative: 'tera'
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
                              ^~~~~~
                              tera
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:276:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:276:5: note: suggested alternative: 'timeWhenDetectingThreadStartedWork'
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     timeWhenDetectingThreadStartedWork
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:317:27: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                           ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:317:27: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:317:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:317:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:323:9: error: 'objectDetectorThreadStartStop' was not declared in this scope
         objectDetectorThreadStartStop.notify_one();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:323:9: note: suggested alternative: 'timeWhenDetectingThreadStartedWork'
         objectDetectorThreadStartStop.notify_one();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         timeWhenDetectingThreadStartedWork
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:330:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.wait(mtx_lock);
         ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:340:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:357:22: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
             mtx_lock.lock();
                      ^~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:364:26: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
                 mtx_lock.unlock();
                          ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:372:13: error: 'objectDetectorRun' was not declared in this scope
             objectDetectorRun.wait(mtx_lock);
             ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:380:22: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
             mtx_lock.unlock();
                      ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:431:18: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.lock();
                  ^~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:447:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.unlock();
                  ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::stop()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:462:25: error: 'mutex' is not a member of 'std'
   std::unique_lock<std::mutex> mtx_lock(mtx);
                         ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:462:25: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:462:30: error: template argument 1 is invalid
   std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:462:41: error: 'mtx' was not declared in this scope
   std::unique_lock<std::mutex> mtx_lock(mtx);
                                         ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:468:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.unlock();
                  ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:479:5: error: 'objectDetectorRun' was not declared in this scope
     objectDetectorRun.notify_one();
     ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:480:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:480:5: note: suggested alternative: 'timeWhenDetectingThreadStartedWork'
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     timeWhenDetectingThreadStartedWork
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:482:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:495:27: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                           ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:495:27: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:495:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:495:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:512:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const cv::Mat&, std::vector<cv::Rect_<int> >&)':
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:533:27: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                           ^~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:533:27: error: 'mutex' is not a member of 'std'
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:533:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:533:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:566:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.notify_one();
         ^~~~~~~~~~~~~~~~~
E:\Application\opencv\opencv_source\modules\objdetect\src\detection_based_tracker.cpp:573:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
mingw32-make[2]: *** [modules\objdetect\CMakeFiles\opencv_objdetect.dir\build.make:119: modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj] Error 1
mingw32-make[2]: Leaving directory 'E:/Application/opencv/mingw-build'
mingw32-make[1]: *** [CMakeFiles\Makefile2:2118: modules/objdetect/CMakeFiles/opencv_objdetect.dir/all] Error 2
mingw32-make[1]: Leaving directory 'E:/Application/opencv/mingw-build'
mingw32-make: *** [Makefile:162: all] Error 2

@alalek
Copy link
Member

alalek commented Dec 10, 2017

Try to run your MinGW compiler with this code:

#include <thread>
#include <mutex>
#include <condition_variable>

std::thread second_workthread;
std::mutex mtx;
std::condition_variable objectDetectorRun;

@viraltailor1
Copy link

I have a same issue please provide me some solution......

@tenderZeitGeist
Copy link
Author

Alright, I just wanted to leave a note, that the problem got solved and I was able to successfully compile the source files into binaries, but I haven't tried to use them. Either way, this issue can be closed.
However, if you want to here the solution to it, I will try my best to explain this issue and how to avoid it in the first place.

When I installed MinGW for the first time, I selected under "Threads" the option "win32", as I thought this was the obvious choice. But to use OpenCV under Windows, you need to select "posix" instead of "win32" threads. This came to my mind while browsing through this thread. In conclusion, if you are not able to compile the source files at this very class/file (detection_based_tracker.cpp.obj), it is very likely due to this.

So, if you are intending of using your own compiled version of OpenCV, I suggest you this:
1.) Download the compiler.
2.) Uninstall your current MinGW compiler.
3.) Reinstall MinGW again.
4.) Understand the option "Threads", chose "posix".

I understand, there are different options and ways, this is sole the way, I handled it. And I hope, it might help one or another C++ or OpenCV rookie.

Cheers.

@alitokur

This comment has been minimized.

@huanghaozi
Copy link

huh sorry sir, i didnt get it. how can i install mingw compiler from the zip?

seems to be....just unzip it....And add "bin" directory to the environment variable...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants