Static compile custom libav based program/application.

Let’s say you come across a scenario where you have to compile a libav based program like one here:

Obviously this can be compiled with make script inside examples folder. Lets say we want to create a custom program outside of all these and just use libav headers and libav static libs to build our program to the final output application, we have to give the dependency of libav libraries properly in order to get it compiled.

the dependency tree is roughly

libavformat –depends-on–> libavcodec  –depends-on–> libavresample  –depends-on–> libavutil

So if you have a file X.c and set of all libav static libs like libavcodec.a, libavformat.a, libavutil.a etc and want to compile that you have to link the libav properly in order for your application file to compile. The final compilation that works is as given below. Here the input file is demux_decode.c and output is video_decoder.

Note the order of “-l” linker options above. It has to be the same when you want to compile your custom program.

Leave a Reply