Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Compiling c++ code give an error "‘nameWindow’ was not declared in this scope"

I have a cpp code like below.

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int main(int argc, const char *argv[])
{
    Mat img(480,640,CV_8UC3,Scalar(255,0,0));
    if(img.empty())
    {
        cout<<"Picture can not load..."<<endl;
        return -1;
    }
    nameWindow("test",CV_WINDOW_AUTOSIZE);
    imshow("test",img);
    waitKey(0);
    destroyWindow("test");
    return 0;
}

When I try to compile this code like below

g++ resimac.cpp

it gives an error

error: ‘nameWindow’ was not declared in this scope
  nameWindow("test",CV_WINDOW_AUTOSIZE);
                                      ^

So what is the problem? How to solve it?