FFmpeg 4.2 开发 报错总结

报错:
FFmpeg看错误编译日志:ffbuild/config.log
错误 1:G:\wang\work\FFmpegAndroid\app\src\main\cpp\include\libavutil\pixfmt.h:29:10: fatal error: ‘libavutil/avconfig.h’ file not found
解决办法:由于avconfig.h文件里面是空的,所以我们可以把引入的该头文件去掉
在这里插入图片描述错误2:In file included from G:\wangqi\work\FFmpegAndroid\app\src\main\cpp\native-lib.cpp:8:
G:\wangqi\work\FFmpegAndroid\app\src\main\cpp\include\libavformat\avformat.h:317:10: fatal error: ‘libavcodec/avcodec.h’ file not found
解决办法:原因是在引入的头文件需要是上一级的目录,修改头文件如下所示

#include "../libavutil/version.h"

错误3:
error: undefined reference to ‘av_version_info()’
原因:ffmpeg是纯C的库,头文件没有做好C++调用的准备 用extern “C”{}套住ffmpeg头文件,用C语言的编译规则来编译ffmpeg代码,就可以了
解决办法:

extern "C"{
    #include <libavutil/avutil.h>
}

错误4:
libavutil/log.c:186: error: undefined reference to ‘stderr’
原因:代码中使用了大量的标准IO设备:stderr 等,这些在NDK15以后,这些都不被支持了,代码本身没问题,只是编译器链接时找不到对应的静态库定义了
解决办法:
在编译选项中添加语句-DANDROID_API=[你的android API版本号]即可; 比如我的测试手机为android 5.1.1 对应 API = 22,编译选项中应该添加:-DANDROID_API=22
adb shell 获取 android 系统版本: adb shell getprop ro.build.version.release
adb shell 获取 android 系统 API 版本: adb shell getprop ro.build.version.sdk
错误5:
libavformat/utils.c:513: error: undefined reference to ‘av_parser_close’
原因:链接静态库先后顺序不正确,引起的符号定义找不到。
解决办法:

1. 修改静态库的链接顺序。
   target_link_libraries(
           native-lib
           avfilter avformat avcodec avutil swresample swscale
           log)
2. 忽略静态库的链接顺序。
   target_link_libraries(
           native-lib
           -Wl,--start-group
           avcodec avfilter avformat avutil swresample swscale
           -Wl,--end-group
           log)

错误6:
libavformat/http.c:1649: error: undefined reference to ‘inflateEnd’
原因:找不到的z库中的函数的实现。因为 ffmpeg 依赖了z库。编译ffmpeg的时候如果仔细看编译时输出的日志,就可以看到 External libraries: zlib
解决办法:添加z库的依赖。

target_link_libraries(
        native-lib
        -Wl,--start-group
        avcodec avfilter avformat avutil swresample swscale
        -Wl,--end-group
        log
        z
)

错误7:
libavformat/hls.c:845: error: undefined reference to ‘atof’
原因:Google have moved some of the C standard library functions like atof() from being inline functions in header files to normal functions. The latest NDKs will default to building a .so that is only compatible with the latest Android devices that have the atof() function in the device’s standard C library (libc.so). This means if you run a library on an older device that has an older version of the C library, you will get an error loading the dll as the expected atof() function will not exist.
解决方法:
修改ffmpeg编译脚本,指定Android API版本为17,重新编译。
错误8:
libavcodec/v4l2_buffers.c:434:44: error: call to ‘mmap’ declared with attribute error: mmap is not available > with _FILE_OFFSET_BITS=64 when using GCC until android-21. Either raise your minSdkVersion, disable > _FILE_OFFSET_BITS=64, or switch to Clang.
解决方法:
所以21版本以下,需要取消 _FILE_OFFSET_BITS宏定义。添加编译参数: -U_FILE_OFFSET_BITS

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值