hi3516a之ffmpeg x264交叉编译

环境:centos_6.5_x86

交叉工具链:arm-hisiv300-linux-

步骤:

1.下载x264:

# git clone git://git.videolan.org/x264.git

2.下载ffmpeg

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

3.交叉编译

  1) [root@demo x264]# ./configure --enable-pthread --enable-static --disable-shared --host=arm-linux --disable-asm

  2)修改config.mak

     SRCPATH=.
prefix=/usr/local
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
includedir=${prefix}/include
SYS_ARCH=ARM
SYS=LINUX
CC=arm-hisiv300-linux-gcc

CFLAGS=-Wshadow -O3 -ffast-math  -Wall -I. -I$(SRCPATH) -std=gnu99 -fomit-frame-pointer -fno-tree-vectorize
COMPILER=GNU
COMPILER_STYLE=GNU
DEPMM=-MM -g0
DEPMT=-MT
LD=arm-hisiv300-linux-gcc -o
LDFLAGS=-L/opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib -lm -L/opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib -lpthread -L/opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/lib -ldl
LIBX264=libx264.a
AR=arm-hisiv300-linux-ar rc
RANLIB=arm-hisiv300-linux-ranlib
STRIP=arm-hisiv300-linux-strip

   3) [root@demo x264]#make 

 [root@demo x264]#make install

        安装路径

install -d /usr/local/bin
install x264 /usr/local/bin
install -d /usr/local/include
install -d /usr/local/lib
install -d /usr/local/lib/pkgconfig
install -m 644 ./x264.h /usr/local/include
install -m 644 x264_config.h /usr/local/include
install -m 644 x264.pc /usr/local/lib/pkgconfig
install -m 644 libx264.a /usr/local/lib
arm-hisiv300-linux-ranlib /usr/local/lib/libx264.a

  4.ffmpeg交叉编译

     [root@demoffmpeg]#./configure  --enable-cross-compile --arch=arm --target-os=linux --enable-static --disable-shared --disable-yasm --enable-memalign-hack --enable-gpl --cc=arm-hisiv300-linux-gcc --enable-libx264  --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --prefix=/usr/local--extra-libs=-ldl

     修改config.mak

     # Automatically generated by configure - do not modify!
ifndef FFMPEG_CONFIG_MAK
FFMPEG_CONFIG_MAK=1
FFMPEG_CONFIGURATION=--enable-cross-compile --arch=arm --target-os=linux --enable-static --disable-shared --disable-yasm --enable-memalign-hack --enable-gpl --cc=arm-hisiv300-linux-gcc --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --prefix=/usr/local --extra-libs=-ldl
prefix=/usr/local
LIBDIR=$(DESTDIR)${prefix}/lib
SHLIBDIR=$(DESTDIR)${prefix}/lib
INCDIR=$(DESTDIR)${prefix}/include
BINDIR=$(DESTDIR)${prefix}/bin
DATADIR=$(DESTDIR)${prefix}/share/ffmpeg
DOCDIR=$(DESTDIR)${prefix}/share/doc/ffmpeg
MANDIR=$(DESTDIR)${prefix}/share/man
PKGCONFIGDIR=$(DESTDIR)${prefix}/lib/pkgconfig
SRC_PATH=.
ifndef MAIN_MAKEFILE
SRC_PATH:=$(SRC_PATH:.%=..%)
endif
CC_IDENT=gcc 4.8.3 (Hisilicon_v300) 20131202 (prerelease)
ARCH=arm
INTRINSICS=none
CC=arm-hisiv300-linux-gcc
CXX=arm-hisiv300-linux-g++
AS=arm-hisiv300-linux-gcc
LD=arm-hisiv300-linux-gcc
DEPCC=arm-hisiv300-linux-gcc

DEPCCFLAGS= $(CPPFLAGS)
DEPAS=arm-hisiv300-linux-gcc
DEPASFLAGS= $(CPPFLAGS)
YASM=yasm
DEPYASM=yasm
AR=arm-hisiv300-linux-ar

      [root@demo ffmpeg]#make
问题总结:

1)ffmpeg undefined reference to symbol 'dlclose'

 configure选项里面加上 --extra-libs=-ldl就可以了

2)报出错误:

x264.c:50:34: error: libavformat/avformat.h: No such file or directory
x264.c:51:30: error: libavutil/pixfmt.h: No such file or directory

  修改config.mak文件的第十行,加上 -I//home/ffmpeg/ffmpeg/ffmpeg 就可以找到了

3)运行make命令后,编译通过,但链接时出错。编译libx264.a库时,显示的命令为:

arm-linux-arlibx264.a ....

    make文件将链接命令和库名字间没有空格,导致系统无法识别此命令 

   手动执行下面的命令:

   arm-hisiv300-linux-ar rc libx264.a common/mc.o common/predict.o common/pixel.o common/macroblock.o common/frame.o common/dct.o common/cpu.o common/cabac.o common/common.o common/osdep.o common/rectangle.o common/set.o common/quant.o common/deblock.o common/vlc.o common/mvpred.o common/bitstream.o encoder/analyse.o encoder/me.o encoder/ratecontrol.o encoder/set.o encoder/macroblock.o encoder/cabac.o encoder/cavlc.o encoder/encoder.o encoder/lookahead.o common/threadpool.o

4)arm-linux-ranlib libx264.a (用于产生x264-config.h文件)


引用相关参考:http://blog.csdn.net/laotie1015/article/details/8295531


你可能感兴趣的:(hi3516a之ffmpeg x264交叉编译)