The actual solution to this problem is to add the opencv bin directory path to the System PATH environment variable.
See this answer for a complete installation of OpenCV in Visual Studio 2010.
There is a drawback to this approach. OpenCV x86 and x64 pre-generated binaries have the same name. Thus, by adding the OpenCV path to the PATH variable, you can either execute the 32-bit version or the 64-bit version at a time. To run another version, you must change the PATH variable.
An alternative to this (my personal favorite) is also to copy the DLL to display the directory, but this is done automatically at the end of the compilation. What I am doing is creating new environment variables for the x86 and x64 dll paths. I am creating user variables CV_BIN32 and CV_BIN64 containing paths to x86 and x64 dll respectively.
After creating custom variables, open the OpenCV project, go to Project Properties β Build Events β Post-Build Event β Command Line .
Add the copy commands for the DLLs that you need at runtime.
This is for Win32 release configuration:
copy "$(CV_BIN32)\opencv_core243.dll" "$(OutDir)" copy "$(CV_BIN32)\opencv_highgui243.dll" "$(OutDir)"
You can change them for all 4 configurations, (Debug / Release), (Win32 / x64)
Now, when the project build procedure is completed, the specified DLLs will be automatically copied to the output directory, and the error will not be shown.
source share