I'm a newbie, and I can't figure out the problem with this code. [closed]

asked 2017-01-16 02:36:17 -0600

kartikeygupta9097 gravatar image

TL;DR - Certain code from OpenCV's own tutorial won't work on my system, when multiple examples already do...

I think I have correctly installed OpenCV 3.2.0 on my i686 system via MinGW 6.2.0, because when I was building my libraries, I also build that contours.cpp example, and it along with 3 other example files worked fine. I have now picked up this tutorial code from OpenCV's own Eclipse CDT documention.

#include <opencv2/opencv.hpp>
using namespace cv;
int main( int argc, char** argv )
  Mat image;
  image = imread( argv[1], 1 );
 if( argc != 2 || !image.data )
      printf( "No image data \n" );
      return -1;
 namedWindow( "Display Image", WINDOW_AUTOSIZE );
 imshow( "Display Image", image );
 return 0;

but it displays the following error on my system...

undefined reference to `cv::imread(cv::String const&, int)'

Please tell me what I'm doing wrong...

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-06 04:46:30.360074


i can't help at all with eclipse (it's a monster !) , but you're not linking your program against opencv libs.

there must be some place labelled like "linker something", where you're supposed to add opencv_world320.a

berak gravatar imageberak ( 2017-01-16 02:48:27 -0600 )edit

have another look here , it's 8b in the tutorial, you have to add opencv_world320 there. (on win, the libs need the version number, but not on linux)

also adjust the library search path (-L) !

berak gravatar imageberak ( 2017-01-16 03:25:41 -0600 )edit

You should link your app with the opencv_highgui.dll

pi-null-mezon gravatar imagepi-null-mezon ( 2017-01-16 07:52:26 -0600 )edit

@pi - can you take a look here - it's opencv3, not 2.4, also an opencv_world lib was built (not single libs).

berak gravatar imageberak ( 2017-01-16 08:10:53 -0600 )edit

@berak - ok, check if your application linked with opencv_world.dll

pi-null-mezon gravatar imagepi-null-mezon ( 2017-01-16 08:33:44 -0600 )edit

Thanks. Not sure what happened, but using opencv_world, instead of using the separate libraries, worked.

kartikeygupta9097 gravatar imagekartikeygupta9097 ( 2017-01-16 10:36:15 -0600 )edit