ffmpeg git build issue: undefined reference to `avcodec_get_context_defaults3'
gst-libav: 1.18.4
ffmpeg: https://github.com/FFmpeg/FFmpeg/commit/5541cffa17a8c45004e5ceeda52d4d6b2acee037
When building gst-libav with the current ffmpeg git the build fails.
[13/13] x86_64-pc-linux-gnu-gcc -m32 -o ext/libav/libgstlibav.so ext/libav/libgstlibav.so.p/gstav.c.o ext/libav/libgstlibav.so.p/gstavprotocol.c.o ext/libav/libgstlibav.so.p/gstavcodecmap.c.o ext/libav/libgstlibav.so.p/gstavutils.c.o ext/libav/libgstlibav.so.p/gstavaudenc.c.o ext/libav/libgstlibav.so.p/gstavvidenc.c.o ext/libav/libgstlibav.so.p/gstavauddec.c.o ext/libav/libgstlibav.so.p/gstavviddec.c.o ext/libav/libgstlibav.so.p/gstavcfg.c.o ext/libav/libgstlibav.so.p/gstavdemux.c.o ext/libav/libgstlibav.so.p/gstavmux.c.o ext/libav/libgstlibav.so.p/gstavdeinterlace.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libgstlibav.so -Wl,--exclude-libs=ALL -O2 -pipe -Wl,-O1 -Wl,--as-needed /usr/lib/libavfilter.so /usr/lib/libavformat.so /usr/lib/libavcodec.so /usr/lib/libavutil.so /usr/lib/libgstreamer-1.0.so /usr/lib/libgobject-2.0.so /usr/lib/libglib-2.0.so /usr/lib/libgstbase-1.0.so /usr/lib/libgstvideo-1.0.so /usr/lib/libgstaudio-1.0.so /usr/lib/libgsttag-1.0.so /usr/lib/libgstpbutils-1.0.so -Wl,--end-group
samu: job failed: x86_64-pc-linux-gnu-gcc -m32 -o ext/libav/libgstlibav.so ext/libav/libgstlibav.so.p/gstav.c.o ext/libav/libgstlibav.so.p/gstavprotocol.c.o ext/libav/libgstlibav.so.p/gstavcodecmap.c.o ext/libav/libgstlibav.so.p/gstavutils.c.o ext/libav/libgstlibav.so.p/gstavaudenc.c.o ext/libav/libgstlibav.so.p/gstavvidenc.c.o ext/libav/libgstlibav.so.p/gstavauddec.c.o ext/libav/libgstlibav.so.p/gstavviddec.c.o ext/libav/libgstlibav.so.p/gstavcfg.c.o ext/libav/libgstlibav.so.p/gstavdemux.c.o ext/libav/libgstlibav.so.p/gstavmux.c.o ext/libav/libgstlibav.so.p/gstavdeinterlace.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libgstlibav.so -Wl,--exclude-libs=ALL -O2 -pipe -Wl,-O1 -Wl,--as-needed /usr/lib/libavfilter.so /usr/lib/libavformat.so /usr/lib/libavcodec.so /usr/lib/libavutil.so /usr/lib/libgstreamer-1.0.so /usr/lib/libgobject-2.0.so /usr/lib/libglib-2.0.so /usr/lib/libgstbase-1.0.so /usr/lib/libgstvideo-1.0.so /usr/lib/libgstaudio-1.0.so /usr/lib/libgsttag-1.0.so /usr/lib/libgstpbutils-1.0.so -Wl,--end-group
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: ext/libav/libgstlibav.so.p/gstavaudenc.c.o: in function `gst_ffmpegaudenc_start':
gstavaudenc.c:(.text+0x7f5): undefined reference to `avcodec_get_context_defaults3'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: ext/libav/libgstlibav.so.p/gstavaudenc.c.o: in function `gst_ffmpegaudenc_set_format':
gstavaudenc.c:(.text+0x864): undefined reference to `avcodec_get_context_defaults3'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: gstavaudenc.c:(.text+0xb7c): undefined reference to `avcodec_get_context_defaults3'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: gstavaudenc.c:(.text+0xca9): undefined reference to `avcodec_get_context_defaults3'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: gstavaudenc.c:(.text+0xce4): undefined reference to `avcodec_get_context_defaults3'
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: ext/libav/libgstlibav.so.p/gstavvidenc.c.o:gstavvidenc.c:(.text+0x1ea): more undefined references to `avcodec_get_context_defaults3' follow
collect2: error: ld returned 1 exit status
samu: subcommand failed
Build log: build.log
This because avcodec_get_context_defaults3
was removed in ffmpeg.
https://github.com/FFmpeg/FFmpeg/commit/ff8f9fcbe558db69f804417d4e9aa2ef9445f304
Reference:
Deprecated: This function should not be used, as closing and opening a codec context multiple time is not supported.
A new codec context should be allocated for each new use.