D:\opencv\build\x64\MinGW>make
[ 2%] Built target libopenjp2
[ 4%] Built target ade
[ 4%] Built target opencv_videoio_plugins
[ 6%] Built target zlib
[ 6%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj
In file included from D:\opencv\sources\modules\core\src\precomp.hpp:49,
from D:\opencv\sources\modules\core\src\algorithm.cpp:43:
D:/opencv/sources/modules/core/include/opencv2/core/utility.hpp:706:14: error: 'recursive_mutex' in namespace 'std' does not name a type
706 | typedef std::recursive_mutex Mutex;
| ^~~~~~~~~~~~~~~
D:/opencv/sources/modules/core/include/opencv2/core/utility.hpp:63:1: note: 'std::recursive_mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
62 | #include <mutex> // std::mutex, std::lock_guard
+++ |+#include <mutex>
63 | #endif
D:/opencv/sources/modules/core/include/opencv2/core/utility.hpp:707:29: error: 'Mutex' is not a member of 'cv'
707 | typedef std::lock_guard<cv::Mutex> AutoLock;
| ^~~~~
D:/opencv/sources/modules/core/include/opencv2/core/utility.hpp:707:29: error: 'Mutex' is not a member of 'cv'
D:/opencv/sources/modules/core/include/opencv2/core/utility.hpp:707:34: error: template argument 1 is invalid
707 | typedef std::lock_guard<cv::Mutex> AutoLock;
| ^
In file included from D:\opencv\sources\modules\core\src\algorithm.cpp:43:
D:\opencv\sources\modules\core\src\precomp.hpp:365:5: error: 'Mutex' in namespace 'cv' does not name a type
365 | cv::Mutex& getInitializationMutex();
| ^~~~~
modules\core\CMakeFiles\opencv_core.dir\build.make:108: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj' failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj] Error 1
CMakeFiles\Makefile2:2006: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:180: recipe for target 'all' failed
make: *** [all] Error 2
以上代码就是出错的地方,在前面安装和使用cmake时都没有什么错误,但是用cmd进行编译装载时出错,看了好几个博客都没有解决,我也不太懂环境配置这方面的东西
希望大佬们可以把解决方法写的详细一些
请问解决了吗?我也遇到了这个问题
遇到同样问题的,你们去看看是不是cmake-gui.exe里的Configure时的gcc.exe和g++.exe是不是弄错了(比如用到了另一个mingw版本的gcc和g++),尤其是电脑里有很多个mingw64的同学……我tm就是这个问题找了整整一个下午加一个晚上
换一个mingw64应该就可以了,我也是这样子的,换成posix的试一下,我一开始用win32也不行,换了好像就好了,注意环境变量配置