Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve 'does not name a type' during opencv compiling using mingw32-make?

I'm trying to compile opencv with extra modules for java (ximgproc). After generating files with Cmake, I tried to use "mingw32-make" command with cmd to generate .jar and .dll, but I got the error below.

I'm following this guide: https://zami0xzami.wordpress.com/2016/03/16/building-java-wrapper-for-opencv/

How can I resolve it?

 C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:175:14: error: 'thread' in namespace 'std' does not name a type
         std::thread second_workthread;
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:176:14: error: 'mutex' in namespace 'std' does not name a type
         std::mutex mtx;
              ^~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:177:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorRun;
              ^~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:178:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorThreadStartStop;
              ^~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::setParameters(const cv::DetectionBasedTracker::Parameters&)':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:30: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:30: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
C:\Users\Jt1995\Desktop\opencv-master\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);
                                                   ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::init()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:30: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:30: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
C:\Users\Jt1995\Desktop\opencv-master\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);
                                                   ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:164:13: error: 'objectDetectorThreadStartStop' was not declared in this scope
             objectDetectorThreadStartStop.notify_one();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In destructor 'virtual cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:254:5: error: 'second_workthread' was not declared in this scope
     second_workthread.join();
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::run()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\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);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\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?
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:275:25: error: 'thread' is not a member of 'std'
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
                         ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:276:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\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);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:323:9: error: 'objectDetectorThreadStartStop' was not declared in this scope
         objectDetectorThreadStartStop.notify_one();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:330:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.wait(mtx_lock);
         ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\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();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\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();
                      ^~~~
C:\Users\Jt1995\Desktop\opencv-master\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();
                          ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:372:13: error: 'objectDetectorRun' was not declared in this scope
             objectDetectorRun.wait(mtx_lock);
             ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\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();
                      ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\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();
                  ^~~~
C:\Users\Jt1995\Desktop\opencv-master\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();
                  ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::stop()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:20: error: 'mutex' is not a member of 'std'
   std::unique_lock<std::mutex> mtx_lock(mtx);
                    ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:20: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:30: error: template argument 1 is invalid
   std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^
C:\Users\Jt1995\Desktop\opencv-master\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);
                                         ^~~
C:\Users\Jt1995\Desktop\opencv-master\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();
                  ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:479:5: error: 'objectDetectorRun' was not declared in this scope
     objectDetectorRun.notify_one();
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:480:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\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();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\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);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\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();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const cv::Mat&, std::vector<cv::Rect_<int> >&)':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\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);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:566:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.notify_one();
         ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\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();
              ^~~~~~
modules\objdetect\CMakeFiles\opencv_objdetect.dir\build.make:121: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj' failed
mingw32-make[2]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj] Error 1
CMakeFiles\Makefile2:3724: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/all' failed
mingw32-make[1]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
like image 960
Jt1995 Avatar asked Aug 08 '17 15:08

Jt1995


1 Answers

It would appear that the compiler does not know about C++ 11 features. You can add support for C++ 11 like this:

set(MY_TARGET_NAME "MyTarget")
target_compile_features(${MY_TARGET_NAME} PUBLIC cxx_std_11)

There is also cxx_std_14 and cxx_std_17 you could add if required.

Here is a list of all CXX features known by CMake : https://cmake.org/cmake/help/v3.10/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES

like image 148
RCYR Avatar answered Oct 05 '22 07:10

RCYR