cffmpeglibavcodeclibavlibavformat

libav - undefined reference to 'av_frame_alloc' and more


I am trying to compile this tutorial from the libav doc: link

I changed nothing on the code!

But when I compile it with:

gcc test.c -lavformat -lswscale -lavdevice -lavformat -lavcodec -lavutil -lpthread -lm -o example

I get these errors:

undefined reference to `check_sample_fmt'
undefined reference to `select_sample_rate'
undefined reference to `select_channel_layout'
undefined reference to `av_frame_alloc'
undefined reference to `av_frame_free'

Searching Dr.google I read that it maybe has something to do with the linking order of the libs. But I did not found the correct one yet?!

EDIT: this 'possible dublicate' seems not to be related to my problem


Solution

  • ffmpeg comes with an Makefile for the examples. I took this one and simply used it for my libav examples. Link