Error 2 error LNK1120: 1 unresolved externals
Error 1 error LNK2019: unresolved external symbol "bool __cdecl identical(class cv::Mat,class cv::Mat)" (?identical@@YA_NVMat@cv@@0@Z) referenced in function _main

this is the error i am getting...tried a lot but still couldnt corrrect it...referred many sites, a guy had this same error but nobody managed to answer it convincingly. hope i get it right here... thank u in advance.

This means the function named identical with that signature cannot be found anywhere. If it's your own code, you haven't written that function. If it's some other code, you haven't linked that library.

no...actually i have the function in my code..but still have that error...

The error indicates clearly that you do not have that function (or rather, the linker cannot find it, which means if you do have it, you're not telling the linker where to find it).

If you show us, for example, the relevant code, we can tell you more.

this is the code:

#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
using namespace cv;
using namespace std;
 bool identical(cv::Mat m1, cv::Mat m2);
int main(int argc, TCHAR *argv[])
{
     //initialize and allocate memory to load the video stream from camera 
     CvCapture *capture = cvCaptureFromCAM(0);

     if( !capture ) return 1;
    IplImage* frst = cvQueryFrame( capture );
    cv::Mat frstMat(frst); 
    bool result;
    //create a window with the title "Video"
    cvNamedWindow("Video");
    while(true)
    {
             //grab and retrieve each frames of the video sequentially 
            IplImage* frame = cvQueryFrame( capture );
             if( !frame ) break;
             cv::Mat framemat( frame ); 
             result = identical(frstMat, framemat);
             if( result == false ) 
                 printf( " Different image" );
             //show the retrieved frame in the "Video" window
             cvShowImage( "Video", frame );
             //wait for 40 milliseconds
             int c = cvWaitKey(40);
          //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27) 
            if((char)c==27 ) break;
   }
   //destroy the opened window
   cvDestroyWindow("Video");   
   //release memory
   cvReleaseCapture( &capture );
    return 0;
}
template<typename T>
bool identical(cv::Mat m1, cv::Mat m2) {
    if(m1.cols != m2.cols || m1.rows != m2.rows)
      return false;

    for(int i=0; i<m1.rows; i++)
    {
       for(int j=0; j<m1.cols; j++)
       {
          if(m1.at<T>(i, j) != m2.at<T>(i, j))
            return false;
       }
    }
    return true;
}

That template function looks odd. Your code never specifies the kind of object that T is to be. A template function is generated at compile time by the compiler, so if the compiler doesn't like it, it won't generate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.