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'
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'