Temporarily replaced with TDM-GCC, similar to MinGW, here is just a statement.
Because the. exe installation package downloaded by OpenCV actually does not have a mingw (GCC) matching/dynamic static library, these things need to be compiled ourselves using MinGW.
The first is the CMake configuration, which executes the cmake directly under the source Directory command line. (Note that there is a space behind and a point number representing the current directory)
In general, it should be possible, then use the Mingw32-make command to complete the compilation (the process is longer), and finally use the Mingw32-make install to generate the required files (header file/dynamic/static Library)
c:.├─include│ ├─opencv│ └─opencv2│ ├─calib3d│ ├─contrib│ ├─core│ ├─features2d│ ├─flann│ ├─gpu│ │ └─device│ │ └─detail│ ├─highgui│ ├─imgproc│ ├─legacy│ ├─ml│ ├─nonfree│ ├─objdetect│ ├─ocl│ ├─photo│ ├─stitching│ │ └─detail│ ├─superres│ ├─ts│ ├─video│ └─videostab└─x86 └─mingw ├─bin └─lib
Add the bin to the system path variable.
Then the Clion Cmakelist.txt is written as follows, which is the simplest library to use, and you can join it later.
Cmake_minimum_required (VERSION 3.2) project (OPENCV) Set (cmake_cxx_flags "-std=c++11") include_directories (c:\\\\ Opencv\\\\include) Set (Source_files main.cpp) set (Target_libs "c:\\\\opencv\\\\x86\\\\mingw\\\\lib\\\\ LIBOPENCV_CORE249.DLL.A "" C:\\\\opencv\\\\x86\\\\mingw\\\\lib\\\\libopencv_highgui249.dll.a "" C:\\\\ OPENCV\\\\X86\\\\MINGW\\\\LIB\\\\LIBOPENCV_IMGPROC249.DLL.A ") add_executable (OpenCV ${source_files}) target_link_ Libraries (OpenCV ${target_libs})
And then write the test code,
1#include"iostream"2#include <opencv2/opencv.hpp>3 using namespacestd;4 using namespaceCV;5 6 intMainintargcChar*argv[]) {7 if(argc!=2){8cout<<"With args in"<<Endl;9 return-2;Ten } OneMat img = imread (argv[1]); A if(Img.empty ()) { -cout <<"Error"<<Endl; - return-1; the } -Imshow ("Lena", IMG); - Waitkey (); - + return 0; -}
Run parameter set to Lena.png
Run the first time to generate the debug directory, and then transfer the lena.png to that directory, you can see correctly:
OPENCV Development Environment Configuration-windows/mingw/clion/cmake