Setup OpenCV-2.3 for Visual Studio 2010

Viewed 67619

I'm trying to use opencv 2.3 with Visual Studio 2010 Express. My code is from example:

#include "stdafx.h"
#include <highgui.h>

int _tmain(int argc, _TCHAR* argv[])
{
    int c;
    // allocate memory for an image
    IplImage *img;
    // capture from video device #1
    CvCapture* capture = cvCaptureFromCAM(1);
    // create a window to display the images
    cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
    // position the window
    cvMoveWindow("mainWin", 5, 5);
    while(1)
    {
        // retrieve the captured frame
        img=cvQueryFrame(capture);
        // show the image in the window
        cvShowImage("mainWin", img );
        // wait 10 ms for a key to be pressed
        c=cvWaitKey(10);
        // escape key terminates program
        if(c == 27)         
            break;
    }

    return 0;
}

What have I done so far?

  • Added build\bin and one of build\{x86|x64}\{vc9\vc10\mingw}\bin to my system path (to use DLLs).
  • Added build\{x86|x64}\{vc9\vc10\mingw}\lib or build\{x86|x64}\{vc9\vc10\mingw}\staticlib as library directories to my linker settings.
  • Added build\include and build\include\opencv as include directories to my compiler settings.

And the result is:

1>LINK : fatal error LNK1104: cannot open file 'c:\OpenCV2.3\build\x86\vc10\lib.obj'

There's no lib.obj in OpenCV folders. I've only unziped OpenCV-2.3.0-win-superpack.exe, without using CMake software.

What am I doing wrong?

3 Answers

If you are struggling with editing the PATH environment variables, you can also copy the required .dll files to your project folder: The dll files are located in this folder ../OpenCV2.3/build.x86/vc9/bin

Then copy them to the folder where .exe file is created: c:\Users\PIMMES\Documents\Visual Studio 2010\Projects\eigenfaces\Debug (Ofcourse you have to change the path to your Debug folder)

You only have to copy the .dll files which you are using in your project (#include for example) For example if you get an error message saying opencv_core231d.dll is not found then get this .dll file from the above location (bin folder) and copy to your project Debug folder.

Hope this helps..

Related