zoukankan      html  css  js  c++  java
  • X264的交叉编译

    1. 下载所需要的X264版本

    2. 写自动化脚本

    #!/bin/sh
    
    CONFIGURE_FLAGS="--enable-static --enable-pic --disable-cli"
    
    ARCHS="arm64 x86_64 i386 armv7 armv7s"
    
    # directories
    SOURCE=""
    FAT=`pwd`/"fat-x264"
    
    SCRATCH=""
    # must be an absolute path
    THIN=`pwd`/"thin-x264"
    
    COMPILE="y"
    LIPO="y"
    
    if [ "$*" ]
    then
    	if [ "$*" = "lipo" ]
    	then
    		# skip compile
    		COMPILE=
    	else
    		ARCHS="$*"
    		if [ $# -eq 1 ]
    		then
    			# skip lipo
    			LIPO=
    		fi
    	fi
    fi
    
    if [ "$COMPILE" ]
    then
    	CWD=`pwd`
    	for ARCH in $ARCHS
    	do
    		echo "building $ARCH..."
    		mkdir -p "$SCRATCH/$ARCH"
    		cd "$SCRATCH/$ARCH"
    		CFLAGS="-arch $ARCH"
                    ASFLAGS=
    
    		if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
    		then
    		    PLATFORM="iPhoneSimulator"
    		    CPU=
    		    if [ "$ARCH" = "x86_64" ]
    		    then
    		    	CFLAGS="$CFLAGS -mios-simulator-version-min=7.0"
    		    	HOST=
    		    else
    		    	CFLAGS="$CFLAGS -mios-simulator-version-min=5.0"
    			HOST="--host=i386-apple-darwin"
    		    fi
    		else
    		    PLATFORM="iPhoneOS"
    		    if [ $ARCH = "arm64" ]
    		    then
    		        HOST="--host=aarch64-apple-darwin"
    			XARCH="-arch aarch64"
    		    else
    		        HOST="--host=arm-apple-darwin"
    			XARCH="-arch arm"
    		    fi
                        CFLAGS="$CFLAGS -fembed-bitcode -mios-version-min=7.0"
                        ASFLAGS="$CFLAGS"
    		fi
    
    		XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
    		CC="xcrun -sdk $XCRUN_SDK clang"
    		if [ $PLATFORM = "iPhoneOS" ]
    		then
    		    export AS="$CWD/$SOURCE/tools/gas-preprocessor.pl $XARCH -- $CC"
    		else
    		    export -n AS
    		fi
    		CXXFLAGS="$CFLAGS"
    		LDFLAGS="$CFLAGS"
    
    		CC=$CC $CWD/$SOURCE/configure 
    		    $CONFIGURE_FLAGS 
    		    $HOST 
    		    --extra-cflags="$CFLAGS" 
    		    --extra-asflags="$ASFLAGS" 
    		    --extra-ldflags="$LDFLAGS" 
    		    --prefix="$THIN/$ARCH" || exit 1
    
    		make -j3 install || exit 1
    		cd $CWD
    	done
    fi
    
    if [ "$LIPO" ]
    then
    	echo "building fat binaries..."
    	mkdir -p $FAT/lib
    	set - $ARCHS
    	CWD=`pwd`
    	cd $THIN/$1/lib
    	for LIB in *.a
    	do
    		cd $CWD
    		lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB
    	done
    
    	cd $CWD
    	cp -rf $THIN/$1/include $FAT
    fi
    
    1. 编译文件
    
    # -rwxr-xr-x 拥有者有读、写、执行权限;而属组用户和其他用户只有读、执行权限。
    
    chmod 755 ./build-x264.sh
    
    # 执行脚本
    
    sudo sh ./build-x264.sh
    
    
    1. 编译完成, 生成fat-x264目录和thin-x264目录,分别存放合并所有指令集的静态库,以及各指令集的静态库.
  • 相关阅读:
    zt 必看: 原来PCIe技术原理这么简单!
    zt linux:centos 解决SSH连接Linux超时自动断开
    idea总结和未来的想法
    linux一些技巧
    zt如何解决Verilog目前不支持数组型端口定义!
    高速设计学习-干货!高速串行Serdes均衡之FFE
    zt:tcpdump抓包对性能的影响
    zt:TCP 学习
    verdi使用
    IE 浏览器下 button元素自动触发click?
  • 原文地址:https://www.cnblogs.com/AliliWl/p/14965557.html
Copyright © 2011-2022 走看看