mac下使用NDK21 Clang编译x264
Posted lcyw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mac下使用NDK21 Clang编译x264相关的知识,希望对你有一定的参考价值。
获取x264源码
从x264官网:https://www.videolan.org/developers/x264.html下载x264源码,
进入x264源码目录下执行 ./configure --help 查看编译选项说明
编译选项
Standard options:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
--bindir=DIR install binaries in DIR [EPREFIX/bin]
--libdir=DIR install libs in DIR [EPREFIX/lib]
--includedir=DIR install includes in DIR [PREFIX/include]
--extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS
--extra-rcflags=ERCFLAGS add ERCFLAGS to RCFLAGS
Configuration options:
--disable-cli disable cli
--system-libx264 use system libx264 instead of internal
--enable-shared build shared library
--enable-static build static library
--disable-bashcompletion disable installation of bash-completion script
--enable-bashcompletion force installation of bash-completion script
--bashcompletionsdir=DIR install bash-completion script in DIR [auto]
--disable-opencl disable OpenCL features
--disable-gpl disable GPL-only features
--disable-thread disable multithreaded encoding
--disable-win32thread disable win32threads (windows only)
--disable-interlaced disable interlaced encoding support
--bit-depth=BIT_DEPTH set output bit depth (8, 10, all) [all]
--chroma-format=FORMAT output chroma format (400, 420, 422, 444, all) [all]
Advanced options:
--disable-asm disable platform-specific assembly optimizations
--enable-lto enable link-time optimization
--enable-debug add -g
--enable-gprof add -pg
--enable-strip add -s
--enable-pic build position-independent code
Cross-compilation:
--host=HOST build programs to run on HOST
--cross-prefix=PREFIX use PREFIX for compilation tools
--sysroot=SYSROOT root of cross-build tree
External library support:
--disable-avs disable avisynth support
--disable-swscale disable swscale support
--disable-lavf disable libavformat support
--disable-ffms disable ffmpegsource support
--disable-gpac disable gpac support
--disable-lsmash disable lsmash support
x264编译脚本
以编译armeabi-v7a架构的x264为例, 使用安装android studio 时as下载的NDK
#!/bin/bash
set -x
export NDK=/Users/wancs/Library/Android/sdk/ndk/21.0.6113669
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/**darwin-x86_64**
export API=21
function build
./configure \\
--prefix=$PREFIX \\
--disable-cli \\
--enable-static \\
--enable-pic \\
--host=$HOST \\
--cross-prefix=$CROSS_PREFIX \\
--sysroot=$NDK/toolchains/llvm/prebuilt/darwin-x86_64/sysroot \\
make clean
make -j8
make install
#armeabi-v7a
PREFIX=./armeabi-v7a
HOST=armv7a-linux-android
export TARGET=armv7a-linux-androideabi
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export CROSS_PREFIX=$TOOLCHAIN/bin/arm-linux-androideabi-
build
如需要编译arm64-v8a架构版本,则修改以下变量:
#arm64-v8a
PREFIX=./android/arm64-v8a
HOST=aarch64-linux-android
export TARGET=aarch64-linux-android
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
CROSS_PREFIX=$TOOLCHAIN/bin/aarch64-linux-android-
以上是关于mac下使用NDK21 Clang编译x264的主要内容,如果未能解决你的问题,请参考以下文章