Issues linking libav (FFMPEG) #2

Open
virtuald opened this Issue Dec 30, 2015 · 2 comments

Projects

None yet

1 participant

@virtuald
Member

In branch libav, built with libav from this branch in roborio-packages.

Basically, it looks like if libav is setup for shared libraries, you end up with something like this:

  • Some exe depends on libopencv_videoio.so
  • libopencv_videoio.so depends on libopencv_highgui.so and libav*.so
  • libopencv_highgui.so depends on libav*.so

The error is something like...

../../lib/libopencv_videoio.so.3.1.0: undefined reference to `av_freep@LIBAVUTIL_54'
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `avformat_write_header@LIBAVFORMAT_56'
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `av_read_frame@LIBAVFORMAT_56'
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `avpicture_get_size@LIBAVCODEC_56'
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `av_free@LIBAVUTIL_54'
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `av_dict_free@LIBAVUTIL_54'
...

And if you look at the rpath entries for libopencv_ libs, it points at the correct path to find the libav modules. However, the link fails, so I suspect for some reason LD isn't recursively adding the rpath as it encounters a new library. When running the compile command with an additional -Wl,-rpath-link,/path/to/libav flag, then it succeeds -- but I can't figure out how to convince cmake to add that for me.

I've spent a bit more time on this than I would like, so I'm giving up for now -- but I'm going to see if statically linking libav will work instead.

@virtuald
Member

I setup libav with --disable-shared --enable-fpic and now OpenCV compiles fine with it. Slightly annoying, as I think I'd rather use the shared library version of livav. The binaries are really large... looks like it's because the debug information wasn't stripped. Will need a better way to separate the debug info from a package and create a separate debug package for it.

I'll have to think about this some more.

@virtuald
Member

I think what I should do is build both in release mode with debug symbols, and in roborio-packages have a step to strip out the symbols automagically. We already have such a step, but it's only executed on things that are installed, and not packages like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment