Opencv 2.3 Compiling Issue - Undefined Refence - Ubuntu 11.10

OpenCV on ubuntu 11.10

Why don't you use pkg-config to your favor?

g++ hello.c -o hello `pkg-config --cflags --libs opencv` 

Strange linker error while compiling OpenCV2.3.1 on Ubuntu 11.10

The problem is that you are attempting to link libopencv_highgui.so with libavcodec.a. The latter is built from code compiled without -fPIC (which is quite usual), and such code can not be linked into shared libraries on x86_64.

Your choices are:

  • Obtain libavcodec.so and arrange to link against it, or
  • Remove libavcodec or -lavcodec from the link line completely.

For the first, you most likely just need to install libavcodec-dev package.

If you do the second, you will still have to arrange for symbols that libopencv_highgui.so needs from libavcodec to be available at runtime. You can achieve that by linking the main executable with libavcodec (either archive or shared variant).

How to build simple OpenCV program

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



Related Topics



Leave a reply



Submit