Tuesday, 29 July 2008

Compiling against libavcodec

When using the libraries supplied with ffmpeg (such as libavcodec, libavfilter etc etc) you must link to the libraries in the following order..

-lavformat -lavcodec -lavdevice -lavutil -lm -lswscale -lavfilter

If you see the error
undefined reference to `BZ2_bzDecompressInit'
Then you must reconfigure and make ffmpeg, adding

--disable-bzlib

to the configuration line.

In this case, the configuration for ffmpeg was...

./configure --disable-vhook --enable-x11grab --enable-gpl --disable-bzlib


Also, remember to bracket the libavcodec header files in extern "C" tags if you are using C++. i.e.

extern "C" {
#include
#include
}

No comments: