gpt4 book ai didi

opencv - 使用mingw32-make编译opencv时如何解决 'does not name a type'?

转载 作者:太空宇宙 更新时间:2023-11-03 20:49:28 25 4
gpt4 key购买 nike

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

我正在遵循本指南: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

最佳答案

编译器似乎不知道 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

关于opencv - 使用mingw32-make编译opencv时如何解决 'does not name a type'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45572971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com