如何使用mingw32-make在opencv编译期间解决'不命名类型'?

时间:2017-08-08 15:57:59

标签: opencv cmake mingw32

我正在尝试使用额外的java(ximgproc)模块编译opencv。使用Cmake生成文件后,我尝试使用cmd生成.mar和.dll的“mingw32-make”命令,但我收到了以下错误。

我正在关注本指南:https://zami0xzami.wordpress.com/2016/03/16/building-java-wrapper-for-opencv/

我该如何解决?

 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

2 个答案:

答案 0 :(得分:5)

看起来编译器不了解C ++ 11的功能。您可以像这样添加对C ++ 11的支持:

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

如果需要,还可以添加cxx_std_14cxx_std_17

以下列出了CMake所知的所有CXX功能:https://cmake.org/cmake/help/v3.10/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES

答案 1 :(得分:0)

使用的编译器未配置为使用C ++ 11进行编译。

如果在RCYR's answer中激活它对您来说不可行,则可以通过将选项ENABLE_CXX11设置为OFF来在构建中切换如果您在命令行中设置它:-DENABLE_CXX11=OFF

请参阅OpenCV的主要CMakeLists.txt

  

OCV_OPTION(ENABLE_CXX11“启用C ++ 11编译模式”“$ {OPENCV_CXX11}”)