我正在尝试从 libav 文档编译本教程: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 我读到它可能与库的链接顺序有关。但我还没找到正确的?!
编辑: 这个“可能的重复”似乎与我的问题无关
最佳答案
您可能正在使用较新版本的 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
关于c - libav - 对 'av_frame_alloc' 等的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32003683/