交叉工具编译ARM平台下X264库

    交叉编译的常见步骤,搭建交叉编译环境,编译,测试。x264为开源代码,请自行前往以下链接下载。

https://www.videolan.org/developers/x264.html

    1.搭建交叉编译环境,搭建成功后,无需重复搭建

sh ~/sdk/android-ndk-r14b/build/tools/make-standalone-toolchain.sh \
        --platform=android-19 --install-dir=/tmp/my_toolchain

    依然使用android-19的api,根据项目需求自行设定。

    2.编译  

#!/bin/sh

export PATH=/tmp/my_toolchain/bin:$PATH
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
export ARM_PRE=arm-linux-androideabi


./configure --disable-gpac --enable-pic --enable-strip --extra-cflags=" \
        -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections \
        -funwind-tables -fstack-protector -fno-short-enums -march=armv7-a \
        -mtune=cortex-a9 -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH_7__ \
        -D__ARM_ARCH_7A__  -Wno-psabi -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 -nostdlib \
        -lc -lm -ldl -lgcc" --cross-prefix=${ARM_PRE}- --host=arm-linux \
        --enable-static --disable-cli --disable-opencl --disable-gpl \
        --disable-interlaced --disable-asm --disable-avs --disable-swscale \
        --disable-lavf --disable-ffms --enable-shared

    由于configure配置太长,所以添加个连接符,如果因为连接符配置失败,请自行去除,配置添加了一些默认优化,可自行修改。

    直接make编译即可,由于这里是给ARM平台下提供库,所以不需要make install

    3.测试

    实测编译通过,动态库和静态库也正常使用。

猜你喜欢

转载自blog.csdn.net/xy_kok/article/details/81383765