VIsual Studio problems

Visual Studio build latest OpenCV package in Debug & Release version. I want to use AddingImage.cpp to test it and build it succesfully with static libraries but on runtime I get an error

---------------------------
ConsoleApplication1.exe - System Error
---------------------------
The code execution cannot proceed because opencv_core470d.dll was not found. Reinstalling the program may fix this problem. 
---------------------------
OK   
---------------------------

if it depends on that dll, you did not link it against static , but dynamic libs
(if that’s ok, at least make sure, the folder containing the opencv dll’s is on the PATH, so they can be found at runtime)

use BUILD_SHARED_LIBS=OFF cmake option to build static opencv libs

if I use dll builld of program I get following error -

Severity Code Description Project File Line Suppression State
Error LNK1107 invalid or corrupt file: cannot read at 0x3D0 ConsoleApplication1 C:\Users\Raivo\opencv-4.7.0\build\bin\Debug\opencv_calib3d470d.dll 1

I build opencv package with Visual Studio twice and got same

Are you adding C:\Users\Raivo\opencv-4.7.0\build\bin\Debug\opencv_calib3d470d.dll to

Properties->Linker->Input->Additional Dependencies?

instead of C:\Users\Raivo\opencv-4.7.0\build\lib\Debug\opencv_calib3d470d.dll?

If so that’s your problem, you need to add the .lib to the linker for compilation and the .dll to your system/user path for runtime.