使用的android ndk的编译版本是android_ndk_r8e
在libx264的源代码目录下建立编译脚本:build_android_r8e.sh,内容如下:
NDK=$HOME/bin/android-ndk-r8e/
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64
CPU=armv7-a
PREFIX=$HOME/projects/dolphin-player/p/native/android/$CPU
ADDITIONAL_CONFIGURE_FLAG="-march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=vfp -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__"
./configure --host=arm-linux \
--prefix=$PREFIX \
--sysroot=$PLATFORM \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--enable-pic \
--enable-strip \
--enable-static \
--extra-cflags=$ADDITIONAL_CONFIGURE_FLAG
make uninstall
make clean
make -j4
make install
configure时会报如下:
Unknown option -mtune=cortex-a8, ignoredUnknown option -mfloat-abi=softfp, ignored
Unknown option -mfpu=vfp, ignored
Unknown option -D__ARM_ARCH_7__, ignored
Unknown option -D__ARM_ARCH_7A__, ignored
可见上面的ADDITION_CONFIGURE_FLAG 中除了-march=armv7-a有用,其余的可能都没有用处.当然这些都不影响编译.
注意:--cross-prefix配置的是编译器的前缀prefix,因此只需要写arm-linux-androideabi-, 而不需要写arm-linux-androideabi-gcc,即不加上后面的gcc,如果加了,反而会报找不到编译器,会用gcc编译,而不是交叉编译器了.
refer to:
http://blog.chinaunix.net/uid-20104447-id-3823071.html