"The program can't start because opencv_world300.dll is missing from your computer" error in C++

I want to compile an opencv Console C++ program in Visual Studio 2013. This is my code:

#include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, const char** argv)
{
    Mat img = imread("rgb_1.png", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'

    if (img.empty()) //check whether the image is loaded or not
    {
        cout << "Error : Image cannot be loaded..!!" << endl;
        //system("pause"); //wait for a key press
        return -1;
    }

    namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
    imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window

    waitKey(0); //wait infinite time for a keypress

    destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"

    return 0;
}

Although I have defined all the directories in properties both in Computer and Visual Studio directories, I get the following error:

"The program can't start because opencv_world300.dll is missing from your computer."

How can I fix this problem?

Under windows you can copy it from:

<your install directory>\opencv30\build\x64\vc12\bin

And put it in your Visual Studio solution (I assume you are using a x64/Release configuration):

<your solution directory>\x64\Release

Or you you can add the above OpenCV to your PATH environment variable

I had the same problem.

I'm on version 320. Once all your environment variables are set make sure your Additional Include Directories, Additional Library Directories and Additional Dependencies are all correct. For me they were $(OPENCV_BUILD)\include;, $(OPENCV_BUILD)\x64\vc14\lib; and opencv_world320d.lib; respectively.

My OPENCV_BUILD path variable is C:\opencv320\build setting the environment variable to %OPENCV_BUILD%\x64\vc14\bin (where the .dll files are located). To get to the Additional things right-click on your project/solution and select properties -> C/C++ for the first and properties -> Linker -> General and Input for the other two.

Restart Visual Studio and if everything was implemented correctly then you should be able to run the program and it should start.

Edit:

Depending on what you used I had to also switch mine from x86 to x64 in the Solution Platforms dropdown.

You can check your system variable to confirm the directory in which opencv_world300.dll is located (maybe C:\opencv\build\x64\vc12\bin) is present.

If it exists but the problem still is not solved, try to put all .dll files in the directory to C:\WINDOWS\system32

If this question is still relevant, I figured out the way.

I presume you used the tutorial on the OpenCV website to setup OpenCV. Once you run the command prompt and execute the command, it creates the environment variable for OpenCVbut it does not add it in the path. So if you go to the path and add the location of the bin in vc12 (vc14 for me), save it, and restart visual studio, it works.

Best and simple solution is

  1. Add path_variable of OpenCV/build/x64/bin in environment system variables.

  2. And then restart the visual studio.

this definitely will solve the problem.

the problem might be you've updated the path variable after opening the visual studio so it can't update the *.dll files.

Comments
  • If you have the dll in question, the easiest thing to do is copy and paste it into your projects executable output folder
  • I've noticed this dll is not placed with other dlls. You need to find out the folder in which opencv_world300.dll is located. That's all.
  • It works and this is great, but I can't figure out why it worked flawlessy before <an unknown action of mine> without the present hack.
  • @RevJohn can you please explain how to do this: "And put it in your Visual Studio solution (I assume you are using a x64/Release configuration): <your solution directory>\x64\Release"
  • Go into system environment variables and scroll down to the "Path" variable, edit it and add "<your install directory>\opencv30\build\x64\vc12\bin" to in (make sure to follow ; syntax and such). Then restart visual studio and you should be set.
  • Even I faced this issue but it got solved by copying the dll, as I'm on a company PC and am not allowed edit the environment variables. Is copying the dll into the solution is the only way out for this issue if I cannot edit the environment variable?
  • Is the system variable is called PATH or are there others ? Does the name of the variable depend on the windows version ? What's the best way to read out the variable (example would be nice) ?
  • Suggesting to copy DLLs into the windows system directory is just terrible. Just set the PATH properly, instead of turning your OS into a mess.