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

1.2使用ndk编译x264

1.下载源码并编译

$cd/opt/android/ndk/android-ndk-r10e/resources

$gitclonehttp://git.videolan.org/git/x264.git

$cdx264

修改configure文件

$vimconfigure

将下面的这四句:

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

【保存并退出】

创建配置脚本

$vimandroid_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

functionbuild_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+xandroid_x264_configure.sh

$./android_x264_configure.sh

platform:ARM

byteorder: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:cropselect_every

debug:no

gprof:no

strip:yes

PIC:yes

bitdepth:8

chromaformat:all

Youcanrun'make'or'makefprofiled'now.

$make

$makeinstall

$ls-Randroid

android:

arm

android/arm:

Android.mkbinincludelib

android/arm/bin:

x264

android/arm/include:

x264_config.hx264.h

android/arm/lib:

libx264.alibx264.sopkgconfig

android/arm/lib/pkgconfig:

x264.pc

$vimandroid/arm/Android.mk

LOCAL_PATH:=$(callmy-dir)

include$(CLEAR_VRS)

LOCAL_MODULE:=libx264

LOCAL_SRC_FILES:=lib/libx264.so

LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/include

include$(PREBUILT_SHARED_LIBRARY)

相关推荐