android平台ffmpeg编译静态库正常,app使用编译好的静态库时报错分析

android平台ffmpeg编译静态库正常,app使用编译好的静态库时报错:
  libavcodec/ffv1enc.c:476: error: undefined reference to 'log2'
  libavcodec/ffv1enc.c:476: error: undefined reference to 'log2'
  libavcodec/ffv1enc.c:476: error: undefined reference to 'log2'
  libavcodec/imc.c:428: error: undefined reference to 'log2f'
  libavcodec/imc.c:374: error: undefined reference to 'log2f'
  libavcodec/imc.c:472: error: undefined reference to 'log2f'
  libavcodec/opusenc.c:274: error: undefined reference to 'log2f'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  
原因:ndk工具链中不同platform级别提供的标准系统库不同,较早版本的platform系统库中没用log2 api reference,比如android-15,而较高版本提供了这些reference,如 android-18.
如果编译ffmpeg库会用了较高的platform,config时生成的config.h中有:
#define HAVE_LOG2 1
#define HAVE_LOG2F 1
反之使用较低的platform时生成的config.h中有: 
#define HAVE_LOG2 0
#define HAVE_LOG2F 0  
当使用较高的platform level编译ffmpeg静态库,而app在使用静态库时设置了较低的platform时,ffmpeg静态库编译时因HAVE_LOG2为1没有将ffmpeg内部提供的log2方法编译进去,在链接时需要外部库提供log2方法。但低版本的ndk标准库又没有提供log2方法的实现,就会出现以上错误。


解决办法:
保证编译ffmpeg静态库和使用ffmpeg静态库版本一致
1,使用较低的android版本编译ffmpeg,如SYSROOT=$NDK/platforms/android-15/arch-arm/
2,app使用较高的android版本,如arguments '-DANDROID_PLATFORM=android-18'



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值