0

Possible Duplicate:
OpenCV: link error, can’t resolve external symbol _cvResize and _cvCvtColor
What is an undefined reference/unresolved external symbol error and how do I fix it?

I have tried all of the tutorials available on their website, and the solutions on stackoverflow, but i still can't find a solution.

What I have already done:

1- added include folder with the headers.

2- added lib folder to the additional lib directories

3- added opencv_core243d.lib and opencv_highgui243d.lib to additional dependencies.

code i'm trying to compile:

#include <stdio.h>
#include <cv.h>
#include <highgui.h>


int main(int argc, char* argv[])
{
if (argc < 2)
{
    printf("Usage: ./opencv_hello <file.png>\n");
    return -1;
}

    IplImage* img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
if (!img)
{
    return -1;
}
cvNamedWindow("display", CV_WINDOW_AUTOSIZE);
    cvShowImage("display", img );

    cvWaitKey(0);        

    return 0;
}

The linker gives errors concerning unresolved symbols such as cvLoadImage, cvWaitKey etc. The only thing i can think of would be the libs, but i have included them already.

Community
  • 1
  • 1
Bartlomiej Lewandowski
  • 10,771
  • 14
  • 44
  • 75

1 Answers1

1

As I understand, you're using the OpenCV 2.4

In this case I would like to suggest using of the C++ interface.

#include <stdio.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

int main(int argc, char* argv[])
{

if (argc < 2)
{
    printf("Usage: ./opencv_hello <file.png>\n");
    return -1;
}

cv::Mat img = imread(argv[1]);
if (img.empty())
{
   return -1;
}

imshow("display", img);

waitKey(0); <---- cvWaitKey() is a C interface functio, waitKey() - C++

return 0;
}
Alex
  • 9,891
  • 11
  • 53
  • 87