I. Introduction of problems:

Ask: Are there any useful tools for developing CPP on Windows? Answer: I blew CLion ask: CLion charge ah: Sorry, my free, education mailbox, direct white piao; Ps: Sorry, sorry, sorry, sorry

Opencv on my MAC is very easy to configure, as is Ubuntu, but Windows is so hard to configure, and many tutorials are based on MinGW. Do I have to be MinGW?

I see Visual Studio configuration is also good, why CLion is so difficult?

Of course not. So how do you do that?

Second, use VCPKG

VCPKG is what? I haven’t heard of it; Use apt? yum? pip? conda? HMM, you mean it’s a package manager? VCPKG is a tool used by Visual Studio to install library files. This is its github address :github.com/Microsoft/v…

2.1. Install VCPKG

Then execute bootstrap-vcpkg.bat. It will generate a vcpkg.exe for you

git clone https://github.com/microsoft/vcpkg
.\vcpkg\bootstrap-vcpkg.bat
Copy the code

You can add vcpkg.exe to the environment variable

2.2. Make sure your Visual Studio has an English language package

2.3 install OpencV

vcpkg install opencv:x64-windows
Copy the code

2.4. Obtain the vcpkg.cmake position

vcpkg integrate intall
Copy the code

2.5 Open CLion and test it

2.5.1 Compiling the cmakelist. TXT configuration file

CMAKE_TOOLCHAIN_FILE is the one generated in 2.4

Cmake_minimum_required (VERSION 3.19) project(myopencv) set(CMAKE_CXX_STANDARD 14) set(CMAKE_TOOLCHAIN_FILE D:/programs/microsoft/vcpkg/scripts/buildsystems/vcpkg.cmake) find_package(opencv REQUIRED) add_executable(myopencv main.cpp) target_link_libraries(myopencv ${OpenCV_LIBS})Copy the code

2.5.2 Write hello World
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main(a) {
    Mat mat=imread(".. /lena.jpg");
    namedWindow("hello");
    imshow("hello",mat);
    waitKey(a);return 0;
}
Copy the code