Rile
Rile

Reputation: 43

undefined reference to cv::inpaint - Error 1

I need a help. Few months ago I make this c++ code in Visual studio on Windows. I make .exe file from that code and everything work fine just like this. That is simple code for image-processing. Now I trying to do same thing in Eclipse on Linux so that I can put executable file on Linux web server. But I have this error:

In function `main':
main.cpp:(.text.startup+0x317): undefined reference to `cv::inpaint(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, double, int)'
collect2: ld returned 1 exit status
make: *** [inpaint] Error 1

I use OpencCV 2.4.1 library. This is source code:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/photo/photo.hpp"
#include <iostream>


using namespace cv;
using namespace std;
Mat img, img0, maska;
int main( int argc, char** argv )
{

...
   }
Mat inpainted;
inpaint(img0, img, inpainted, 2, CV_INPAINT_NS);
char imeobr[256] = "images/img-uploads/finish";
strcat( imeobr, argv[1] );
strcat( imeobr, ".jpg" );
imwrite(imeobr, inpainted);
return 0;
}

I think that is a problem in input source, because is not a fixed name of input images. But, I need dynamically change input source for every user of application. Please help people. What I can do?

Upvotes: 1

Views: 4716

Answers (2)

Yu Tao
Yu Tao

Reputation: 798

you need to include:

-lopencv_photo

Upvotes: 3

Luca Davanzo
Luca Davanzo

Reputation: 21528

Undefined reference error happens when you omit to link a library:

in the preferences of your project:

C/C++ Build -> GCC C++ Linker -> Libraries

have you entered libopencv_imgproc library in Libraries(-l)?

update

Just for testing, I've created my program:

#include <opencv/highgui.h>
#include <opencv/cv.h>

using namespace cv;

int main(int argc, char* argv[]) {
  Mat img, img0;
  Mat inpainted;
  inpaint(img0, img, inpainted, 2, CV_INPAINT_NS);
}

in libraries I've linked:

opencv_imgproc 
opencv_highgui
opencv_core

Everything works fine.. Try it and tell me!

Upvotes: 3

Related Questions