1

I wrote a simple test program for opencv to see if it's working after I compiled my OpenCV 2.4 in visual studio 2010 pro.

The program goes like this:

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

using namespace cv;
using namespace std;

int main()
{
    Mat im = imread("c:/full/path/to/lena.jpg");
    if (im.empty()) 
    {
        cout << "Cannot load image!" << endl;
        return -1;
    }
    imshow("Image", im);
    waitKey(0);
}

The thing is that the program compiles without problems ( I've set all the lib paths and include paths in visual studio), but when I try to run it, it gives me the following error message winow: "The program can't start because opencv_core240d.dll is missing from your computer. Try reinstalling the program to fix this problem"

Now, I've read that this could be solved by setting the windows PATH variable to the directory where the actual .dll file is located by doing a cmd command:

SET PATH="C:\Program Files (x86)\OpenCV\opencv\build\bin\Debug"

The path specified is indeed the path where the .dll file is located however, I still get the error.

Help would really be appreciated since I've spent far too much time cocking around this...

1 Answer 1

4

You will have to run your program from the same command line from where you set the PATH(after setting the path, of course).

If you are trying to run it from some other place, you should set the PATH env. variable in the Control Panel -> System first(*), then restart your command line/IDE to have the new PATH in effect

(*) Control Panel -> System -> Advanced System Settings -> Environment Variables on Windows 7

Sign up to request clarification or add additional context in comments.

1 Comment

Lol, forgot to restart ide after setting the variable. Nevertheless, you saved me a lot of time, thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.