Opencv Unixlike build fails on Cygwin

[ 2%] Processing OpenCL kernels (core)
[ 2%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj
In file included from C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/src/precomp.hpp:53,
from C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/src/algorithm.cpp:43:
C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/include/opencv2/core/utility.hpp:718:14: error: ‘recursive_mutex’ in namespace ‘std’ does not name a type
718 | typedef std::recursive_mutex Mutex;
| ^~~~~~~~~~~~~~~
C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/include/opencv2/core/utility.hpp:63:1: note: ‘std::recursive_mutex’ is defined in header ‘’; did you forget to ‘#include ’?
62 | #include // std::mutex, std::lock_guard
+++ |+#include
63 | #endif
C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/include/opencv2/core/utility.hpp:719:29: error: ‘Mutex’ is not a member of ‘cv’
719 | typedef std::lock_guardcv::Mutex AutoLock;
| ^~~~~
C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/include/opencv2/core/utility.hpp:719:29: error: ‘Mutex’ is not a member of ‘cv’
C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/include/opencv2/core/utility.hpp:719:34: error: template argument 1 is invalid
719 | typedef std::lock_guardcv::Mutex AutoLock;
| ^
In file included from C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/src/algorithm.cpp:43:
C:/cygwin64/home/Raivo/opencv-4.6.0/modules/core/src/precomp.hpp:369:5: error: ‘Mutex’ in namespace ‘cv’ does not name a type
369 | cv::Mutex& getInitializationMutex();
| ^~~~~
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/build.make:104: modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1807: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

please DONT use cygwin for this.

you need a different mingw(64) g++, built with posix threads
(so it has the missing mutex / threads headers)

e.g. this one:
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z/download

Thank for assistants !

I am using now Eclipse IDE with simple program with opencv and got similar errors errors

Description Resource Path Location Type
‘Mutex’ is not a member of ‘cv’ first line 719, external location: C:\Users\Raivo\opencv\build\include\opencv2\core\utility.hpp C/C++ Problem
‘recursive_mutex’ in namespace ‘std’ does not name a type first line 718, external location: C:\Users\Raivo\opencv\build\include\opencv2\core\utility.hpp C/C++ Problem

wrong compiler, again …

also, you will have to disable WITH_MSMF and WITH_OBSSENSOR
(NO version of mingw has supporting code for this !)

Thank You, I changed in eclipse buid type and insted of cross compiler I use minGV, but i Got new errors

Description Resource Path Location Type
Function ‘waitKey’ could not be resolved second.cpp /second/src line 39 Semantic Error
Symbol ‘cv’ could not be resolved second.cpp /second/src line 13 Semantic Error
Type ‘Mat’ could not be resolved second.cpp /second/src line 27 Semantic Error

Code looks like -
#include “opencv2/imgcodecs.hpp”
#include “opencv2/highgui.hpp”
#include

using namespace cv;

and where to set these variables also, you will have to disable WITH_MSMF and WITH_OBSSENSOR
(NO version of mingw has supporting code for this !)

cmake options for building the opencv libs

add:

#include “opencv2/opencv.hpp"

i’ve NO idea, what you did there.
however, all those are compiler errors, you probably need to fix your include path

assuming, you did a proper make install (DID YOU ?), that should be:

c:/wherever/opencv/is/build/install/opencv2/include

I’ll send You the screenshot. May be it helps. I using opencv4.6 binary install

please NO screenshots from your ide (entirely useless)

if you meant a binary release – those libs are only usable for VS compiler.

if you want to use mingw, you MUST build from src

FIrstly I used Visual Studio, but I got following error at runtime.

Project1.exe - System Error

The code execution cannot proceed because opencv_world460.dll was not found. Reinstalling the program may fix this problem.

OK

I rebuil opncv 4.6 and 4.7 from sources but same error occure.

What’s wron with me ?

folder containing this dll must be on the PATH, so the exe can find it at runtime

Thank You very much ! All works now

you’re too lazy to even spellcheck ‘wrong’

1 Like

You have the patience of a saint! :joy:

1 Like

I have 1 question more. Is it possible to set opencv install building from sources with VIsual Studio in this way that it doesn’t makes the tests

there are BUILD_TESTS=OFF and BUILD_PERF_TESTS=OFF
cmake options

How can I set them. I’m novice in cmake