您的位置:首页 > 移动开发 > Android开发

libx264 for android编译(重点是看那个configure如何配置)

2016-03-21 16:57 507 查看
1.2 使用ndk编译x264
1. 下载源码并编译
$ cd /opt/android/ndk/android-ndk-r10e/resources
$ git clone http://git.videolan.org/git/x264.git
$ cd x264


修改configure文件
$ vim configure
将下面的这四句:
else
echo "SOSUFFIX=so" >> config.mak
echo "SONAME=libx264.so.$API" >> config.mak
echo "SOFLAGS=-shared -Wl, -soname, \$(SONAME)$SOFLAGS" >> config.mak
中的这句:
echo "SONAME=libx264.so.$API" >> config.mak
改成:
echo "SONAME=libx264.so" >> config.mak
【保存并退出】


创建配置脚本
$ vim android_x264_configure.sh
#!/bin/bash
NDK=/opt/android/ndk/android-ndk-r10e
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64


function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--enable-static \
--disable-gpac \
--disable-cli \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--host=arm-linux \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
}
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS=""

build_one
【保存并退出】


$ chmod +x android_x264_configure.sh
$ ./android_x264_configure.sh
platform: ARM
byte order: little-endian
system: LINUX
cli: no
libx264: internal
shared: yes
static: yes
asm: yes
interlaced: yes
avs: avxsynth
lavf: no
ffms: no
mp4: no
gpl: yes
thread: posix
opencl: yes
filters: crop select_every
debug: no
gprof: no
strip: yes
PIC: yes
bit depth: 8
chroma format: all


You can run 'make' or 'make fprofiled' now.


$ make
$ make install
$ ls -R android
android:
arm


android/arm:
Android.mk bin include lib


android/arm/bin:
x264


android/arm/include:
x264_config.h x264.h


android/arm/lib:
libx264.a libx264.so pkgconfig


android/arm/lib/pkgconfig:
x264.pc


$ vim android/arm/Android.mk
LOCAL_PATH := $(call my-dir)


include $(CLEAR_VRS)
LOCAL_MODULE := libx264
LOCAL_SRC_FILES := lib/libx264.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY) 阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: