Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

undefined reference to `cv::fastFree(void*)' & 'cv::Mat::deallocate()'

I am doing template matching on eclipse CDT using C++ API.

The code is :

#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/mat.hpp"
#include "opencv/cv.hpp"
using namespace cv;

#include <iostream>
#include <stdio.h>
using namespace std;


/// Global Variables
IplImage* img;
IplImage* templ;
IplImage* result;
char* image_window = "Source Image";
char* result_window = "Result window";

int match_method;
int max_Trackbar = 5;

int main( int argc, char** argv )
{
    img = cvLoadImage("C:\\Users\\..\\workspace\\OpenCV_CPP\\src\\myimg.png",true);
    templ = cvLoadImage("C:\\Users\\...\\workspace\\OpenCV_CPP\\src\\mytmp.png",true);

    /// Create windows
    cvNamedWindow( image_window, CV_WINDOW_AUTOSIZE );
    cvNamedWindow(result_window, CV_WINDOW_AUTOSIZE );
    Mat img_display;
    CvArr* msk2;
    cvCopy(&img,&img_display,&msk2);
      /// Create the result matrix
      int result_cols =  img->width - templ->width + 1;
      int result_rows = img->height - templ->height + 1;
      CvSize cs = cvSize(result_cols,result_rows);
      cvCreateImage(cs,CV_32FC1,3);
      match_method = 0;
      /// Do the Matching and Normalize
      cvMatchTemplate(&img,&templ,&result,match_method);
      CvArr* msk1;
      cvNormalize(&result,&result,0,1,NORM_MINMAX,&msk1);
      double minVal; double maxVal; CvPoint minLoc; CvPoint maxLoc;
      Point matchLoc;
      CvArr* msk;
      cvMinMaxLoc( &result, &minVal, &maxVal, &minLoc, &maxLoc, &msk);
      matchLoc = minLoc;
      if( match_method  == 0 || match_method == 1 )
        { matchLoc = minLoc; }
      else
        { matchLoc = maxLoc; }
      cvRectangle( &img_display, matchLoc, Point( matchLoc.x + templ->height , matchLoc.y + templ->height ), Scalar::all(0), 2, 8, 0 );
      cvRectangle( &result, matchLoc, Point( matchLoc.x + templ->width , matchLoc.y + templ->height ), Scalar::all(0), 2, 8, 0 );
      cvShowImage(image_window, &img_display);
      cvShowImage(result_window, &result);
      cvWaitKey(0);
      cvReleaseImage(&img );
      cvReleaseImage(&templ );
      cvReleaseImage(&result );
    return 0;
}

On compilation, I get 2 errors :-

C:/OpenCV-3.0/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to cv::fastFree(void*)' src\DisplayImage.o: In functionZN2cv3Mat7releaseEv': C:/OpenCV-3.0/opencv/build/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'

Please suggest on how to deal with them.