Visual Studio configuration
1) Install the toolchain
- Visual Studio 2019/2022 with Desktop development with C++ or MSVC Build Tools.
- Target x64 (Win32/x86 is not supported by most modern builds).
- Install CMake if your project uses it (recommended for portability).
2) Install OpenCV for Windows
- Use the official installer for OpenCV 4.12.0.
- Note the installation path (it contains include, lib, and bin directories).
3) Project include and library paths
- Add the include directory to your project’s Additional Include Directories.
- Add the lib directory to Additional Library Directories.
- Add the appropriate OpenCV libraries to Linker → Input (e.g., combined world library for your config).
4) Runtime DLL availability
- Ensure that OpenCV DLLs are available at runtime.
- Either add the bin folder to your system/user PATH or place required DLLs next to your executable.
- Match Debug vs Release and x64 vs x86 consistently across your project and libraries.
5) Optional: Using CMake projects
- Point your CMAKE_PREFIX_PATH to the OpenCV installation so that your build system can find it.
- Regenerate your build files after setting the prefix/path to ensure detection.
Common pitfalls and quick fixes
- “DLL not found” at runtime: add OpenCV bin to PATH or deploy DLLs alongside the executable.
- Unresolved externals: ensure you linked the correct libraries for your configuration (Release vs Debug) and platform (x64).
- MSVC runtime mismatch: use the same toolset/runtime across dependencies; avoid mixing 2019 and 2022 libs.
- Wrong architecture: verify that project, OpenCV, and all third-party libs are built for x64.