libav - 对'av_frame_alloc'的未定义引用等

问题描述 投票:0回答:2

我正在尝试从libav doc:link编译本教程

我没有改变代码!

但是当我编译它时:

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

我收到这些错误:

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'

搜索Dr.google我读到它可能与libs的链接顺序有关。但我没找到正确的呢?!

编辑:这个'可能的dublicate'似乎与我的问题无关

c ffmpeg libavcodec libav libavformat
2个回答
1
投票

您可能正在使用较新版本的FFmpeg运行旧代码。 Ffmpeg更改了一些函数名称,一些创建了一些折旧警告,而另一些则创建了错误。

根据官方Ffmpeg github

av_frame_alloc(), av_frame_unref() and av_frame_free() now can and should be 
used instead of avcodec_alloc_frame(), avcodec_get_frame_defaults() and avcodec_free_frame() respectively

0
投票

ffmpeg附带了一个Makefile用于示例。我拿了这个,只是将它用于我的libav示例。 Link

© www.soinside.com 2019 - 2024. All rights reserved.