15.Linux shell programming (compiling ffmpeg)

Keywords: Linux Android Programming Windows

(Created in 2018/2/5)

This script can be compiled normally, but it does not rule out the problem after copying to Linux. Pay attention to the seriousness of Linux programming. Excess space will lead to problems.

Before the script is compiled, commands need to be executed in the ffmpeg directory for a series of preparations, such as checking the version of gcc.
Generate files such as config. map. Note that once generated, they will not be regenerated, so there is a problem if you are on a Linux computer.
Or, after execution on another computer, config and so on are generated, and then you transfer it to the Windows system and execute it again without regenerating the file coverage.
The resulting file environment is still the previous system, so it causes problems

./configure --disable-yasm      //-- disable-yasm is to disable yasm, if you execute it directly. / configure will be prompted

tip: Execute the following commands to see help

./configure --help
#!/bin/bash

#Global variables, multiple shell scripts can be used
export ANDROID_NDK_HOME=/usr/ndk/android-ndk-r10e
export PLATFORM_VERSION=android-9

function build_ffmpeg
{
    echo "start build ffmpeg $ARCH"
    ./configure --target-os=linux \     //Note that there is a space behind linux, and then \\\\\\\\\\\\
    --prefix=$PREFIX \                  //File directories placed in dynamic libraries after compilation
    --arch=$ARCH \
    --enable-shared \
    --disable-static \
    --disable-yasm \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-doc \
    --enable-cross-compile \
    --cross-prefix=$CROSS_COMPILE \
    --sysroot=$PLATFORM \
    --extra-cflags="-fpic"                //The last command does not add \\\\\\\\\
    make clean                            //Delete. o Temporary File
    make
    make install

    echo "build finished $ARCH"
}

#exec 1>jason_build_stdout.txt
#exec 2>jason_build_stdout.txt
#arm
ARCH=arm                                  //CPU architecture
CPU=arm                                   //CPU
PREFIX=$(pwd)/android/$CPU                //Location of dynamic libraries, current pwd directory
TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi-
PLATFORM=$ANDROID_NKD_HOME/platforms/$PLATFORM_VERSION/arch-$ARCH
build_ffmpeg

#x86
ARCH=x86
CPU=x86
PREFIX=$(pwd)/android/$CPU
TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/x86-4.9/prebuilt/linux-x86_64
CROSS_COMPILE=$TOOLCHAIN/bin/i686-linux-android-
PLATFORM=$ANDROID_NKD_HOME/platforms/$PLATFORM_VERSION/arch-$ARCH
build_ffmpeg

Posted by LarryK on Thu, 24 Jan 2019 17:51:14 -0800