使用NDK交叉编译ffmpeg+libx264找不到libx264的解决方法
使用NDK交叉编译ffmpeg+libx264
1,编译libx264
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar xjvf last_x264.tar.bz2
cd x264-snapshot*
使用如下confiure
export ARM_ROOT=/home/zangcf/cross_compile/Android-ndk-r9b
export ARM_INC=$ARM_ROOT/platforms/android-8/arch-arm/usr/include/
export ARM_LIB=$ARM_ROOT/platforms/android-8/arch-arm/usr/lib/
export ARM_TOOL=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
export ARM_LIBO=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8
export PATH=$ARM_TOOL/bin:$PATH
export ARM_PRE=arm-linux-androideabi
./configure --prefix=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build \
--extra-cflags=" -I$ARM_INC -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack -MMD -MP " \
--extra-ldflags=" -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o -lc -lm -ldl -lgcc " \
--cross-prefix=${ARM_PRE}- --disable-asm --host=arm-linux
make
make install
make distclean
2,下载编译ffmpeg
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
使用如下configure
export ARM_ROOT=/home/zangcf/cross_compile/android-ndk-r9b
export ARM_INC=$ARM_ROOT/platforms/android-8/arch-arm/usr/include/
export ARM_LIB=$ARM_ROOT/platforms/android-8/arch-arm/usr/lib/
export ARM_TOOL=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
export ARM_LIBO=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8
export PATH=$ARM_TOOL/bin:$PATH
export ARM_PRE=arm-linux-androideabi
export LIB_INC=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/include
export LIB_LIB=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/lib
./configure --target-os=linux \
--arch=armv5te \
--enable-cross-compile \
--cc=$ARM_TOOL/bin/${ARM_PRE}-gcc \
--cross-prefix=$ARM_TOOL/bin/${ARM_PRE}- \
--extra-cflags=" -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -D
ANDROID -Wa,--noexecstack -MMD -MP " \
--enable-static \
--disable-shared --enable-libx264 --enable-gpl \
--disable-asm --disable-yasm \
--prefix=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build \
--disable-amd3dnow --disable-amd3dnowext --disable-mmx --disable-sse --disable-ssse3 \
--extra-cflags="-I$ARM_INC -std=gnu99 -I$LIB_INC " \
--extra-libs="-lc -lm -ldl -lgcc -lz -lx264 " \
--extra-ldflags=" -L$LIB_LIB -Wl,-rpath-link=$LIB_LIB -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so
-Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o "
/////////////////////////////////////////////////////////////////////
执行configure的时候,怎么都提示找不到h264,经过仔细分析研读,分析configure文件,发现是x264的编译选项有问题,少了一个--enable-static
加上这个选项,重新编译x264,呵呵ffmpeg的配置编译都通过了。
make
make install
make distclean
hash -r
FFmpeg 的详细介绍:请点这里
FFmpeg 的下载地址:请点这里
推荐阅读: