The VS2022 used is the Professional version of the official website, and the OpenCV version is 4.7.0
1. Download OpenCV
Official website download address: Releases - OpenCV
Select the Windows version to download and decompress to the local disk. It is recommended that the path does not contain Chinese. My decompression installation address is:
C:\opencv
2. Configure Windows environment variables
My Computer-Properties-Advanced System Settings-Advanced-Environment Variables-System Variables (user variables are also available)-Path-Edit-New, add C:\opencv\build\x64\vc16\bin
3. Configure the project property parameters in VS2022
VS2022 opens or creates a new project XX:
1. Right click on the project - Properties - VC++ directory
The "include directory" on the right is newly added: C:\opencv\build\include
The "Library Directory" on the right is added: C:\opencv\build\x64\vc16\lib
2. Click on the linker - input
Added in "Additional Dependencies" on the right: opencv_world470d.lib
Tips: There may be 2 lib files in the C:\opencv\build\x64\vc16\lib directory, select the lib whose file name ends with "d".
Don't forget to click "Apply" and "OK" at the end!
4. Verification
As you can see, there is no error message when importing opencv.hpp.