error: 'recursive_mutex' in namespace 'std' does not name a type
typedef std::recursive_mutex Mutex;
^~~~~~~~~~~~~~~
error: 'Mutex' is not a member of 'cv'
typedef std::lock_guard AutoLock;
^~
error: template argument 1 is invalid
typedef std::lock_guard AutoLock;
После попытки найти ошибку в Интернете, я попытался построить OpenCV из источника (загруженного с github) с помощью Cmake-gui и Mingw32-Make Install . К сожалению, ему не удалось построить из -за той же ошибки. < /P>
PS D:\opencv_bfs> mingw32-make install
[ 0%] Built target opencv_dnn_plugins
[ 0%] Built target opencv_highgui_plugins
[ 1%] Built target jpeg12-static
[ 2%] Built target jpeg16-static
[ 5%] Built target libjpeg-turbo
[ 7%] Built target libopenjp2
[ 7%] Built target opencv_videoio_plugins
[ 8%] Built target zlib
[ 8%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj
In file included from C:\Users\luong\Downloads\opencv-4.12.0\modules\core\src\precomp.hpp:53:0,
from C:\Users\luong\Downloads\opencv-4.12.0\modules\core\src\algorithm.cpp:43:
C:/Users/luong/Downloads/opencv-4.12.0/modules/core/include/opencv2/core/utility.hpp:788:14: error: 'recursive_mutex' in namespace 'std' does not name a type
typedef std::recursive_mutex Mutex;
^~~~~~~~~~~~~~~
C:/Users/luong/Downloads/opencv-4.12.0/modules/core/include/opencv2/core/utility.hpp:789:25: error: 'Mutex' is not a member of 'cv'
typedef std::lock_guard AutoLock;
^~
C:/Users/luong/Downloads/opencv-4.12.0/modules/core/include/opencv2/core/utility.hpp:789:25: error: 'Mutex' is not a member of 'cv'
C:/Users/luong/Downloads/opencv-4.12.0/modules/core/include/opencv2/core/utility.hpp:789:34: error: template argument 1 is invalid
typedef std::lock_guard AutoLock;
^
In file included from C:\Users\luong\Downloads\opencv-4.12.0\modules\core\src\algorithm.cpp:43:0:
C:\Users\luong\Downloads\opencv-4.12.0\modules\core\src\precomp.hpp:393:5: error: 'Mutex' in namespace 'cv' does not name a type
cv::Mutex& getInitializationMutex();
^~~~~
modules\core\CMakeFiles\opencv_core.dir\build.make:105: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj' failed
mingw32-make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj] Error 1
CMakeFiles\Makefile2
mingw32-make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:164: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
После проверки ядра/include/opencv2/core/utility.hpp я обнаружил некоторые ошибки в
#ifndef OPENCV_DISABLE_THREAD_SUPPORT
typedef std::recursive_mutex Mutex; // 'recursive_mutex' in namespace 'std' does not name a type
typedef std::lock_guard AutoLock; // 'Mutex' is not a member of 'cv'. template argument 1 is invalid
Цитирование с https://github.com/opencv/opencv/blob/8 ... y.hpp#l787, 787, 787, 787, 787, 787, 787, 787, 7877, 787, 787, 7877, 787, 787, 787, 787, 787, 787, 787, 7887, 7887, 7887, 788 789. < /P>
версия компилятора: < /p>
gcc --version
gcc.exe (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
< /code>
g++.exe (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
< /code>
cmake --version
cmake version 4.1.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
< /code>
After trying update MinGW, I found another error.
MinGW ver:
g++ --version
g++.exe (i686-win32-dwarf-rev0, Built by MinGW-Builds project) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
< /code>
Errors:
Starting build...
cmd /c chcp 65001>nul && C:\MinGW\bin\g++.exe -fdiagnostics-color=always -std=c++14 -g D:\Code\Cpp\ComputerVision\src\main.cpp -o D:\Code\Cpp\ComputerVision\build\main.exe -I C:/opencv/build/include -L C:/opencv/build/x64/vc16/bin
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/15.2.0/../../../../i686-w64-mingw32/bin/ld.exe: C:\Users\luong\AppData\Local\Temp\cc1CfYtD.o: in function `main':
D:/Code/Cpp/ComputerVision/src/main.cpp:15:(.text+0x86): undefined reference to `cv::imread(std::__cxx11::basic_string const&, int)'
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/15.2.0/../../../../i686-w64-mingw32/bin/ld.exe: D:/Code/Cpp/ComputerVision/src/main.cpp:17:(.text+0x93): undefined reference to `cv::Mat::empty() const'
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/15.2.0/../../../../i686-w64-mingw32/bin/ld.exe: D:/Code/Cpp/ComputerVision/src/main.cpp:23:(.text+0x10e): undefined reference to `cv::imshow(std::__cxx11::basic_string const&, cv::_InputArray const&)'
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/15.2.0/../../../../i686-w64-mingw32/bin/ld.exe: D:/Code/Cpp/ComputerVision/src/main.cpp:24:(.text+0x139): undefined reference to `cv::waitKey(int)'
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/15.2.0/../../../../i686-w64-mingw32/bin/ld.exe: D:/Code/Cpp/ComputerVision/src/main.cpp:27:(.text+0x14b): undefined reference to `cv::Mat::~Mat()'
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/15.2.0/../../../../i686-w64-mingw32/bin/ld.exe: D:/Code/Cpp/ComputerVision/src/main.cpp:27:(.text+0x1a6): undefined reference to `cv::Mat::~Mat()'
collect2.exe: error: ld returned 1 exit status
Build finished with error(s).
< /code>
System specification:
Edition: Windows 10 Pro
Version: 22H2
OS Build: 19045.6216
Processor Intel(R) Core(TM) i5-7440HQ CPU @ 2.80GHz 2.81 GHz
Installed RAM 24.0 GB (23.8 GB usable)
Graphics Card NVIDIA GeForce 940MX (2 GB), Intel(R) HD Graphics 630 (128 MB)
System Type 64-bit operating system, x64-based processor
Подробнее здесь: https://stackoverflow.com/questions/797 ... -namespace