Reputation: 129
I am trying to build the program at http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html after installing OpenCV on my machine. I try to compile it using g++ display_image.cpp -o DisplayImage
but I get the following error:
display_image.cpp:(.text+0x9d): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
I think this has to do with how I'm compiling the program (some unresolved reference to opencv2) but I don't know how to resolve it. I'm using Ubuntu 13.04. Thanks!
Edit: I realize this is similar to OpenCV 2.3 Compiling Issue - Undefined Refence - Ubuntu 11.10 but I don't really understand the use of pkg-config opencv --cflags --libs
and how to avoid it
Upvotes: 0
Views: 535
Reputation: 8509
You got a linker error because you didn't specify OpenCV on your GCC command line
Follow that tutorial (http://opencv.willowgarage.com/wiki/CompileOpenCVUsingLinux) link your sample with OpenCV
Upvotes: 1