I'm trying to set up OpenCV, some basic code to just start with it and see what I can do. But every time I try to compile the app, I get errors saying
'Mutex' is not a member of 'cv'
. Tried some of other solutions, for eg. this
My environment is VS Code with c_cpp_properties.json
set as this:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}",
"C:\\MinGW\\lib\\gcc\\mingw32\\8.2.0\\include\\c++",
"C:\\MinGW\\lib\\opencv\\build\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "C:\\MinGW\\posix\\mingw64\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
Tried few reinstalls of g++
and all that minGW
stuff, nothing works.
That's my code of main.cpp
:
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <string>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
const string file_name = "sunflower.jpg";
Mat img = imread(file_name);
if( !img.data )
{
cout << "Nie odnalezionu pliku " << file_name;
return -1;
}
const string window_name = "OpenCV_1";
namedWindow(window_name, WINDOW_AUTOSIZE);
imshow(window_name, img);
waitKey(0);
return 0;
}
Console output
Executing task: g++ -g -o bin/debug.exe src/main.cpp -IC:\MinGW\lib\opencv\build\include -LC:\MinGW\lib\opencv\build\x64\vc15\bin -llibopencv_highgui242 -llibopencv_features2d242 -llibopencv_flann242 -llibopencv_objdetect242 -llibopencv_video242 -llibopencv_calib3d242 -llibopencv_contrib242 -llibopencv_imgproc242 -llibopencv_core242 -llibopencv_ml242 -llibopencv_legacy242 -llibopencv_nonfree242 -llibopencv_photo242 -llibopencv_stitching242 -llibopencv_videostab242 <
In file included from C:\MinGW\lib\opencv\build\include/opencv2/core.hpp:3290,
from C:\MinGW\lib\opencv\build\include/opencv2/highgui.hpp:46,
from C:\MinGW\lib\opencv\build\include/opencv2/highgui/highgui.hpp:48,
from src/main.cpp:1:
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:697:14: error: 'recursive_mutex' in namespace 'std' does not name a type
typedef std::recursive_mutex Mutex;
^~~~~~~~~~~~~~~
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:697:9: note: 'std::recursive_mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:60:1:
+#include <mutex>
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:697:9:
typedef std::recursive_mutex Mutex;
^~~
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:29: error: 'Mutex' is not a member of 'cv'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~~~~
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:29: note: suggested alternative: 'Matx'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~~~~
Matx
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:29: error: 'Mutex' is not a member of 'cv'
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:29: note: suggested alternative: 'Matx'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~~~~
Matx
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:34: error: template argument 1 is invalid
typedef std::lock_guard<cv::Mutex> AutoLock;
^
The terminal process terminated with exit code: 1
I'm in need of a solution to configure g++ in a way to compile the application. Or do something I'm yet not aware of.