0

When I try to compile the code bellow this error occurs any body know what is the problem?

#include <opencv2/highgui.hpp>

using namespace cv;

int main(void)
{
    Mat img(200, 200, CV_8U);

    for (int i = 0; i < 200; ++i)
        for (int j = 0; j < 200; ++j)
            img.at<unsigned char> (i, j) = std::min(i+j, 255);

    namedWindow("Example 2");
    imshow("Example 2", img);
    waitKey(0);

    return 0;
}

cv1.cpp:(.text+0x36): undefined reference to `cv::Mat::Mat(int, int, int)'

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • you need to link against opencv_core and opencv_highgui libs – berak Mar 11 '22 at 11:06
  • 1
    Does this answer your question? [Cannot get OpenCV to compile because of undefined references?](https://stackoverflow.com/questions/24337932/cannot-get-opencv-to-compile-because-of-undefined-references) – Yunus Temurlenk Mar 11 '22 at 11:14
  • @YunusTemurlenk unfortunately that is not working either – Hamid Mohammadi Mar 11 '22 at 11:51
  • "not working"... show what precisely you did, and what happened. please review [mre]. put that information in your question. you can [edit] it. do not post additional information as an "answer" when that isn't an answer. – Christoph Rackwitz Mar 11 '22 at 12:14

1 Answers1

0

You have to include this

#include <opencv2/opencv.hpp>
balu
  • 1,023
  • 12
  • 18