Visual Studios 2010 program cannot start because opencv_core243.dll is missing

I learn how to use OpenCV, and, as a practice, I ran the program (in Release mode, x64). I had 0 compiler errors, but a pop-up screen appeared that said:

"the program cannot start because opencv_core243.dll is missing"

However, I made sure that I specified the correct environment variables and specified the required libraries / directories. My problem was fixed when I copied the following DLL files to x64 / Release:

  • opencv_core243.dll
  • opencv_highgui243.dll
  • opencv_imgproc243.dll

My program now compiles and works. However, I would like to know why. It’s nice to copy and paste these DLL files. I skipped the step when these .dll files will be generated automatically?

+4
source share
1 answer

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.

+4
source

All Articles