Search code examples
c++visual-studio-2010visual-studioopencvrelease-mode

Opencv Sample code not working in Visual studio


I downloaded opencv 2.4.5 and tried to configure in Visual studio 11. I tried compiling the below code in Debug mode by following the steps from this link. It works fine.

But the same code get crahes in release mode.

The below is the code.

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

using namespace cv;

int main()
{
    Mat img(Mat::zeros(100, 100, CV_8U));

    imshow("window", img);

    waitKey();

    return 0;
}

Solution

  • As my guess, there may be a linkage problem. For release mode you need to link with release static libraries For example, if a debug library is opencv_imgproc243d.lib, its release version is opencv_imgproc243.lib