win7+cygwin环境下ffmpeg 3.0.2 android库编译总结

win7+cygwin环境下ffmpeg 3.0.2 android库编译总结

./configure --prefix=F:/android/android-ndk-r10b/sources/ffmpeg-release-3.0/android/arm --enable-shared --disable-static --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-symver --enable-gpl --cross-prefix=F:/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi- --target-os=linux --arch=arm --cpu=cortex-a8 --enable-cross-compile --sysroot=F:/android/android-ndk-r10b/platforms/android-18/arch-arm/ --extra-cflags='-Os -fpic -marm' --extra-version=cdkj-build2016.0827.1000
make clean V=1 or make clean
rm -rf android/arm/include/
rm -rf android/arm/lib/
make V=1 or make
make install V=1 or make install

./configure --prefix=F:/android/android-ndk-r10b/sources/ffmpeg-3.2/android/arm --enable-shared --disable-static --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-symver --enable-gpl --enable-jni --enable-mediacodec --cross-prefix=F:/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi- --target-os=android --arch=arm --cpu=cortex-a8 --enable-cross-compile --sysroot=F:/android/android-ndk-r10b/platforms/android-18/arch-arm/ --extra-cflags='-Os -fpic -marm' --extra-version=cdkj-build2016.1122.1500
make clean V=1 or make clean
rm -rf android/arm/include/
rm -rf android/arm/lib/
make V=1 or make
make install V=1 or make install


configure error:
/cygdrive/f/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file.
C compiler test failed.
config.log:
arm-linux-androideabi-gcc.exe: error: missing argument to '-mcpu='
arm-linux-androideabi-gcc.exe: error: /tmp/ffconf.AkKnG6qh.c: No such file or directory
arm-linux-androideabi-gcc.exe: fatal error: no input files
compilation terminated.
C compiler test failed.

solve:
configure命令选项增加:--cpu=cortex-a8

很明显是/tmp/ffconf.xxx.c文件没找到。但/tmp不是ffmpeg中的目录,应该是临时目录。所以呢,在运行config.sh编译前先设置cygwin的环境变量 export TMPDIR=D:/Android/cygwin/tmp 就可以
export TMPDIR=F:/android/tmp,不要使用/cygdrive/f/android/tmp,/cygdrive/f/android/tmp这个路径也算无效;

configure error:
/cygdrive/f/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file.
C compiler test failed.
config.log:
f:/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtbegin_dynamic.o: No such file or directory
f:/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtend_android.o: No such file or directory
f:/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lc
f:/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -ldl
collect2.exe: error: ld returned 1 exit status
solve:
configure命令选项里面的/cygdrive/f/ ---> F:/
--prefix=/cygdrive/f/android/android-ndk-r10b/sources/ffmpeg-release-3.0/android/arm -->
--prefix=F:/android/android-ndk-r10b/sources/ffmpeg-release-3.0/android/arm
--cross-prefix=/cygdrive/f/android/android-ndk-r10b/toolchains -->
--cross-prefix=F:/android/android-ndk-r10b/toolchains
--sysroot=/cygdrive/f/android/android-ndk-r10b/platforms/android-18/arch-arm/ -->
--sysroot=F:/android/android-ndk-r10b/platforms/android-18/arch-arm/

configure error:
Creating config.mak, config.h, and doc/config.texi...
./configure: line 1383: cmp: command not found
./configure: line 1383: cmp: command not found
solve:
You need to install the cygwin diffutils package.
再次运行cygwin的安装文件setup.exe,一直下一步到Select Packages,然后Search diffutils,把把需要的包Default-->Install即可

build error:
./libavutil/libm.h: At top level:
./libavutil/libm.h:423:22: error: static declaration of 'rint' follows non-static declaration
static inline double rint(double x)
^
./libavutil/libm.h:430:43: error: static declaration of 'lrint' follows non-static declaration
static av_always_inline av_const long int lrint(double x)
^
./libavutil/libm.h:437:43: error: static declaration of 'lrintf' follows non-static declaration
static av_always_inline av_const long int lrintf(float x)
^
./libavutil/libm.h:444:41: error: static declaration of 'round' follows non-static declaration
static av_always_inline av_const double round(double x)
^
./libavutil/libm.h:451:40: error: static declaration of 'roundf' follows non-static declaration
static av_always_inline av_const float roundf(float x)
^
./libavutil/libm.h:458:41: error: static declaration of 'trunc' follows non-static declaration
static av_always_inline av_const double trunc(double x)
^
./libavutil/libm.h:465:40: error: static declaration of 'truncf' follows non-static declaration
static av_always_inline av_const float truncf(float x)
^
make: *** [libavdevice/alldevices.o] Error 1
解决办法
在config.h搜索lrint、lrintf、round、roundf等对于的字符
#define HAVE_LLRINT 1
#define HAVE_LLRINTF 1
#define HAVE_LRINT 1
#define HAVE_LRINTF 1
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
将对于的值改为1即可


./config.h:17:19: error: expected identifier or '(' before 'void'
#define getenv(x) NULL
^
/home/cd008/diska/android-ndk-r9/platforms/android-18/arch-arm/usr/include/stdlib.h:54:14: note: in expansion of macro 'getenv'
extern char *getenv(const char *);
^
./config.h:17:19: error: expected ')' before numeric constant
#define getenv(x) NULL
^
/home/cd008/diska/android-ndk-r9/platforms/android-18/arch-arm/usr/include/stdlib.h:54:14: note: in expansion of macro 'getenv'
extern char *getenv(const char *);
解决办法:
在config.h中注释掉#define getenv(x) NULL
/*#define getenv(x) NULL*/


build error:
LD libavutil/libavutil.so.55
LD libswscale/libswscale.so.4
f:/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: libavutil/libavutil.so:1:1: syntax error, unexpected '!', expecting $end
f:/android/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: libavutil/libavutil.so: not an object or archive
collect2.exe: error: ld returned 1 exit status
library.mak:111: recipe for target 'libswscale/libswscale.so.4' failed
make: *** [libswscale/libswscale.so.4] Error 1
解决办法:
008@008-PC /cygdrive/f/android/android-ndk-r10b/sources/ffmpeg-release-3.0
$ cp -d libavutil/libavutil.so libavutil/libavutilbk1.so
$ ls libavutil/*.so* -la
lrwxrwxrwx 1 008 None 15 七月 13 17:40 libavutil/libavutil.so -> libavutil.so.55
-rwxrwx---+ 1 008 None 1132732 七月 13 17:40 libavutil/libavutil.so.55
lrwxrwxrwx 1 008 None 15 七月 13 17:52 libavutil/libavutilbk1.so -> libavutil.so.55
$ rm libavutil/libavutil.so
$ ls libavutil/*.so* -la
-rwxrwx---+ 1 008 None 1132732 七月 13 17:40 libavutil/libavutil.so.55
lrwxrwxrwx 1 008 None 15 七月 13 17:52 libavutil/libavutilbk1.so -> libavutil.so.55
$ cp libavutil/libavutil.so.55 libavutil/libavutil.so

或者修改configure文件:
android)
disable symver
enable section_data_rel_ro
SLIB_INSTALL_NAME='$(SLIBNAME)'
SLIB_INSTALL_LINKS=
SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)'
;;

linux)
enable dv1394
enable section_data_rel_ro
;;
----> 增加ln_s="cp -f"
android)
disable symver
enable section_data_rel_ro
ln_s="cp -f"
SLIB_INSTALL_NAME='$(SLIBNAME)'
SLIB_INSTALL_LINKS=
SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)'
;;

linux)
ln_s="cp -f"
enable dv1394
enable section_data_rel_ro
;;

参考:
$ make
LD libavcodec/libavcodec-55.so
c:/users/home/development/cygwin/tmp/ffmpeg/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: libavutil/libavutil.so:1:1: syntax error, unexpected ‘!’, expecting $end
c:/users/home/development/cygwin/tmp/ffmpeg/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: libavutil/libavutil.so: not an object or archive
collect2: ld returned 1 exit status
library.mak:106: recipe for target `libavcodec/libavcodec-55.so’ failed
make: *** [libavcodec/libavcodec-55.so] Error 1
解决办法:
Mike says: November 5, 2013 at 8:57 am
ok.. I found out this is a symbolic link problem. Maybe NDK still dosen’t support cygwin fully.
*Solution.
1) backup these original symbolic links or remove
libavutil/libavutil.so
libavcodec/libavcodec.so

2) copy these symbolic links to files
libavutil/libavutil-52.so -> libavutil.so
libavcodec/libavcodec-55.so -> libavcodec.so

android apk error:
07-15 13:59:22.632: E/art(2135): dlopen("/data/app/com.demo.openglshow-1/lib/arm/libswresample-2.so", RTLD_LAZY) failed: dlopen failed: could not load library "libavutil.so.55" needed by "libswresample-2.so"; caused by library "libavutil.so.55" not found
07-15 13:59:22.635: E/AndroidRuntime(2135): FATAL EXCEPTION: GLThread 39119
07-15 13:59:22.635: E/AndroidRuntime(2135): Process: com.demo.openglshow, PID: 2135
07-15 13:59:22.635: E/AndroidRuntime(2135): java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "libavutil.so.55" needed by "libswresample-2.so"; caused by library "libavutil.so.55" not found
解决办法:
修改configure文件:
#SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'

#LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'

#SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'

#SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'

LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'

SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'
很多ffmpeg编译资料上面说要修改configure文件 ,说的原因是 如果不修改的话,在android上 System.loadLibrary('xxx'); 的时候个别so库无法加载的问题。
打开 ffmpeg源码内 configure 文件进行如下修改:
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB)'$(LIBDIR)/$(LIBNAME)''
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR)$(SLIBNAME)'
替换为:
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB)'$(LIBDIR)/$(LIBNAME)''
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值