Download the official OpenCV Windows binary
Download opencv-4.12.0-windows.exe from the download page or from github.com/opencv/opencv/releases. Run the self-extracting archive and extract to C:\opencv.
Add OpenCV bin to Windows PATH
Before configuring Visual Studio, add the OpenCV bin directory to your system PATH so Windows can find the DLLs at runtime:
- 1
Open Environment Variables
Win+S → search Edit the system environment variables → click Environment Variables.
- 2
Edit System Path
Under System variables, click Path → Edit → New.
- 3
Add the bin path
C:\opencv\build\x64\vc16\binClick OK on all dialogs. Restart Visual Studio for the change to take effect.
Configure Visual Studio project
For each Visual Studio project that uses OpenCV, set these three properties. Right-click your project → Properties.
| Property page | Setting | Value |
|---|---|---|
| C/C++ → General | Additional Include Directories | C:\opencv\build\include |
| Linker → General | Additional Library Directories | C:\opencv\build\x64\vc16\lib |
| Linker → Input | Additional Dependencies | opencv_world4120.lib (Release) or opencv_world4120d.lib (Debug) |
Verify the setup with a minimal test
C++ setup questions
opencv_world4120.dll was not found
C:\opencv\build\x64\vc16\bin to your system PATH and restart Visual Studio and your terminal. See opencv_world.dll fix guide.LNK1107: invalid or corrupt file: cannot read
opencv_world4120.lib. For Debug builds use opencv_world4120d.lib. Make sure your project configuration (Release/Debug) matches the lib file.