bytestorm
bytestorm

Reputation: 1531

OpenCV program wouldn't compile on Visual Studio 2010

I am trying to compile a very simple OpenCV (2.4.9) program in Visual Studio 2010 just to check whether opencv libraries have been linked properly. Here is the program code I am trying to run.

#include "stdafx.h"
#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char** argv )
{
    Mat image;
    image = imread( "MyPic.jpg", 1 );

    if ( !image.data )
    {
        printf("No image data \n");
        return -1;
    }
    namedWindow("Display Image", CV_WINDOW_AUTOSIZE );
    imshow("Display Image", image);

    waitKey(0);

    return 0;
}

But when I press the build button, the compilation fails and shows the following error.

1>LINK : fatal error LNK1104: cannot open file 'opencv_gpu249.lib'

What the problem could be? How to solve it?

enter image description here

Upvotes: 0

Views: 265

Answers (1)

herohuyongtao
herohuyongtao

Reputation: 50657

You need to add the OpenCV library path to the Visual Studio's Library Directories:

OpenCV-2.4.9-Path\build\x86\vc10\lib

or for 64bits

OpenCV-2.4.9-Path\build\x64\vc10\lib

Upvotes: 1

Related Questions