ffmpeg 静态库使用,undefined reference错误

ffmpeg移植到dm365上,遇到undefined reference错误:

GA/gabin/lib/libavformat.a(allformats.o): In function `av_register_all':
/GA/ffmpeg-0.10/libavformat/allformats.c:53: undefined reference to `avcodec_register_all'
/GA/gabin/lib/libavformat.a(amr.o): In function `amr_read_packet':
/GA/ffmpeg-0.10/libavformat/amr.c:153: undefined reference to `av_new_packet'
/GA/ffmpeg-0.10/libavformat/amr.c:169: undefined reference to `av_free_packet'
/GA/gabin/lib/libavformat.a(anm.o): In function `read_header':
/GA/ffmpeg-0.10/libavformat/anm.c:89: undefined reference to `av_log_ask_for_sample'
/GA/ffmpeg-0.10/libavformat/anm.c:166: undefined reference to `av_log_ask_for_sample'
/GA/gabin/lib/libavformat.a(ape.o): In function `ape_read_packet':
/GA/ffmpeg-0.10/libavformat/ape.c:372: undefined reference to `av_new_packet'
/GA/gabin/lib/libavformat.a(applehttp.o): In function `free_variant_list':
/GA/ffmpeg-0.10/libavformat/applehttp.c:131: undefined reference to `av_free_packet'
/GA/gabin/lib/libavformat.a(applehttp.o): In function `reset_packet':
/GA/ffmpeg-0.10/libavformat/applehttp.c:151: undefined reference to `av_init_packet'
/GA/ffmpeg-0.10/libavformat/applehttp.c:151: undefined reference to `av_init_packet'
/GA/gabin/lib/libavformat.a(applehttp.o): In function `applehttp_read_seek':
/GA/ffmpeg-0.10/libavformat/applehttp.c:712: undefined reference to `av_free_packet'
/GA/gabin/lib/libavformat.a(applehttp.o): In function `reset_packet':


网上查阅,普遍提示两种解决方法:

一、ffmpeg是纯C的库,应用程序用C++来编译。

二、路径、需要的库包含不全。

以上具体就不说了,搜索下便是。

我在无数遍仔细确认上述两种可能性后,仍然报错。郁闷了一个晚上。。

后来查阅ffmpeg的 pkg-config,终于找到原因,错误导致过程让我痛苦,原因却很简单。

错误:gcc  test.c -o test -I/GA/gabin/include/ -L/GA/gabin/lib  -lavcodec -lavformat  -lavdevice -lavutil -pthread  -ldl -lswscale -lSDL -lbz2  -lasound -lz -lm  

调整: gcc  test.c -o test -I/GA/gabin/include/ -L/GA/gabin/lib  -lavformat  -lavdevice -lavcodec  -lavutil -pthread  -ldl -lswscale -lSDL -lbz2  -lasound -lz -lm  

问题解决,同志需要注意包依赖关系。





  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值