linux 交叉编译ffplay,Linux下ffmpeg交叉编译

1 获取源代码

git clone -b "branch" https://git.ffmpeg.org/ffmpeg.git

“branch” 可以是以下的master、release/3.1等等,具体看需要使用哪个分支。

2 Configure配置

在源码的目录下调用configure脚本,通过 -h 查看相应的帮助,这里写了一个简单的脚本build-ffmpeg.sh;

#!/bin/bash

PREFIX=out

TOOLCHAINS=/mnt/diska/X3399/source/buildroot/output/host/opt/ext-toolchain/bin

CROSS_COMPILE=${TOOLCHAINS}/aarch64-linux-gnu-

LOCAL_PATH=`pwd`

CFLAGS="-Wall -pipe -fpic \

-finline-limit=300 -ffast-math \ -fstrict-aliasing -Werror=strict-aliasing \ -fmodulo-sched -fmodulo-sched-allow-regmoves \ -Wno-psabi -Wa,--noexecstack"EXTRA_CFLAGS=

EXTRA_LDFLAGS=

CPU_NAME=cortex-a72

FFMPEG_FLAGS="--prefix=${PREFIX} \

--target-os=linux \ --arch=arm \ --cpu=$CPU_NAME \ --enable-cross-compile \ --cross-prefix=${CROSS_COMPILE} \ --enable-shared \ --disable-symver \ --disable-doc \ --disable-ffplay \ --disable-ffmpeg \ --disable-ffprobe \ --disable-ffserver \ --disable-avdevice \ --disable-avfilter \ --disable-muxers \ --disable-filters \ --disable-devices \ --disable-everything \ --enable-protocols \ --enable-parsers \ --enable-demuxers \ --disable-demuxer=sbg \ --enable-decoders \ --enable-bsfs \ --enable-network \ --enable-swscale \ --enable-neon \ --enable-version3 \ --disable-yasm \ --disable-asm"

#--enable-debug \

#--disable-stripping \

#--disable-optimizations \

./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" --extra-ldflags="$LDFLAGS $EXTRA_LDFLAGS"

#make && make install

3 报错处理

如果在根目录下直接执行build-ffmpeg.sh脚本是无法成功安装ffmpeg的,首先这里会出现以下几个问题。

报错1:

错误内容:

{your path to toolchians}/aarch64-linux-gnu-gcc is unable to create an executable file. C compiler test failed.

解决方案:

打开configure文件;

搜索报错内容“C compiler test failed”,定位到以下内容,注释掉 die “C compiler test failed.” 或者修改 if 条件使得条件一直成立也是可以的。 if test "$?" != 0; then

echo "$cc is unable to create an executable file."

if test -z "$cross_prefix" && ! enabled cross_compile ; then

echo "If $cc is a cross-compiler, use the --enable-cross-compile option."

echo "Only do this if you know what cross compiling means."

fi

# die "C compiler test failed."

fi

报错2

错误内容:

If you think configure made a mistake, make sure you are using the latest

version from Git. If the latest version fails, report the problem to the

ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.

Include the log file “config.log” produced by configure as this will help

solve the problem.

解决方案:

和报错1的解决方案类似,需要定位configure文件中的错误信息提示内容,

die(){

echolog "$@"

cat <

If you think configure made a mistake, make sure you are using the latest

version from Git. If the latest version fails, report the problem to the

ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.

EOF

if disabled logging; then

cat <

Rerun configure with logging enabled (do not use --disable-logging), and

include the log this produces with your report.

EOF

else

cat <

Include the log file "$logfile" produced by configure as this will help

solve the problem.

EOF

fi

# exit 1

}

简单粗暴一点将exit 1直接注释掉,这样就不会退出了,但是会遇到什么问题不得而知,至少目前可以成功安装了。

报错3

错误内容:

aarch64-linux-gnu-gcc: error: missing argument to ‘-mcpu=’

解决方案:

configure 参数中加入 –cpu=$CPU_NAME 选项

4 At last

最后将out文件夹下的 文件copy到目标板上即可

本文同步分享在 博客“小麦大叔”(CSDN)。

如有侵权,请联系 support@oschina.cn 删除。

本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值