cmake链接ffmpeg静态链接库 undefined reference错误

利用cmake生成makefile文件编译项目时出现undefined reference错误,导致编译失败,经网上资料的查询可知需要调整ffmpeg库的连接顺序libavformat、libavdevice、libavcodec、libavutil、libpthread、libswscale、libswresample。

完成顺序调整后,如果仍出现以下报错,则说明未将libswresample链接至程序文件,导致报错。

/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_subpacket':
../ffmpeg/libavcodec/opusdec.c:346: undefined reference to `swr_is_initialized'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
../ffmpeg/libavcodec/opusdec.c:187: undefined reference to `swr_is_initialized'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_init_resample':
../ffmpeg/libavcodec/opusdec.c:135: undefined reference to `swr_init'
../ffmpeg/libavcodec/opusdec.c:141: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
../ffmpeg/libavcodec/opusdec.c:201: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_flush_resample':
../ffmpeg/libavcodec/opusdec.c:89: undefined reference to `swr_convert'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_subpacket':
../ffmpeg/libavcodec/opusdec.c:378: undefined reference to `swr_close'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_flush':
../ffmpeg/libavcodec/opusdec.c:581: undefined reference to `swr_close'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_close':
../ffmpeg/libavcodec/opusdec.c:605: undefined reference to `swr_free'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_init':
../ffmpeg/libavcodec/opusdec.c:674: undefined reference to `swr_alloc'
collect2: error: ld returned 1 exit status
CMakeFiles/***.dir/build.make:167: recipe for target '***' failed
make[2]: *** [***] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/***/all' failed
make[1]: *** [CMakeFiles/***.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

重新将所有链接库链接配置修改后生成编译,便完成ffmpeg的链接与编译

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值