OPENCV Development Environment Configuration-windows/mingw/clion/cmake

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.