1、编译时遇到问题
1.编译的时候出现如下错误:
.........
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/imgutils.h:80:28: error: 'uint8_t' was not declared in this scope
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/imgutils.h:80:37: error: 'data' was not declared in this scope
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/imgutils.h:80:46: error: expected primary-expression before 'enum'
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/imgutils.h:80:74: error: expected primary-expression before 'int'
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jniinclude/libavutil/imgutils.h:81:28: error: 'uint8_t' was not declared in this scope
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/imgutils.h:81:37: error: 'ptr' was not declared in this scope
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jniinclude/libavutil/imgutils.h:81:42: error: expected primary-expression before 'const'
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/imgutils.h:81:64: error: expression list treated as compound expression in initializer [-fpermissive]
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/imgutils.h:93:20: error: 'uint8_t' was not declared in this scope
.......
解决办法:这是因为找不到uint8_t这些定义,网上说什么修改ffmpeg里面的某个common.h头文件加上这些定义什么的呀,其实完全不用这么做,本身有个系统文件是有这些定义的,加上头文件#include <inttypes.h>即可,注意需要加在引用ffmpeg头文件之前。
此问题解决办法引用:http://blog.csdn.net/cjj198561/article/details/33417965
2、编译时遇到问题
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/common.h: In function 'int32_t av_clipl_int32_c(int64_t)':
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/common.h:205:47: error: 'UINT64_C' was not declared in this scope
解决办法:这个时候需要手动在你的代码里面加上几句代码,注意需要加在引用ffmpeg头文件之前。直接上代码:
#ifndef __MICloudPub___H264Decoder__
#define __MICloudPub___H264Decoder__
#ifndef UINT64_C
#define UINT64_C(value) __CONCAT(value, ULL)
#endif
#endif
3、编译出现问题:
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/MyLibrary.cpp:19: error: undefined reference to 'avcodec_register_all()'
collect2: error: ld returned 1 exit status
明明有这个头文件和函数,但就是找不到。
解决办法:
在Android.mk中添加如下一句话:
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
4、问题:
/Users/zhaodebo/workspace/code/MyNdk/app/src/main/jni/include/libavutil/avutil.h:209:1: error: expected initializer before 'ring'
ring(enum AVMediaType media_type);
解决办法:
关键词“expected initializer before...”是说在before后面提示地方附近有语法错误,注意排查。