利用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/liba