0

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

4
  • 1
    looks like you forget to link with OpenCV lib with a -l or -L.... Commented Jul 23, 2013 at 20:14
  • possible duplicate of OpenCV 2.3 Compiling Issue - Undefined Refence - Ubuntu 11.10 Commented Jul 23, 2013 at 20:21
  • You can't avoid the use of pkg-config... Commented Jul 23, 2013 at 20:26
  • 1
    pkg-config [package] --cflags --libs returns the compiler flags and libraries that you need to add to gcc command in order to use [package] in your computer. You can avoid the use if you already know the output of that command and use it directly Commented Jul 23, 2013 at 20:49

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.