交叉编译mplayer

来源:互联网 发布:办公室网络兼职 编辑:程序博客网 时间:2024/06/05 19:18

    因项目需要,花了几天交叉编译mplayer,遇到很多坑,网上也参考了好多资料,总算编译好了,现记录一下:

    一、交叉编译libmad 

   1.首先下载libmad,我下载的版本为:libmad-0.15.1b.tar.gz 

    2.解压,输入配置指令:

    $sudo ./configure CC=/opt/gcc-linaro-arm-linux-gnueabihf-4.9/bin/arm-linux-gnueabihf-gcc --host=arm-linux --enable-fpm=arm --enable-shared --enable-static --prefix=/usr/local/libmab

    3.修 fixed.h文件(参考http://blog.csdn.net/m190753089/article/details/50625702)

# define MAD_F_MLN(hi, lo) \

asm ("rsbs %0, %2, #0\n\t" \

"rsc %1, %3, #0" \

: "=r" (lo), "=r" (hi) \

: "0" (lo), "1" (hi) \

: "cc")

改为

#ifdef __thumb__

/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero

operand. If needed this code can also support Thumb-1

(simply append "s" to the end of the second two instructions). */

# define MAD_F_MLN(hi, lo) \

asm ("rsbs %0, %0, #0\n\t" \

" sbc %1, %1, %1\n\t" \

"sub %1, %1, %2" \

: "+&r" (lo), "=&r" (hi) \

: "r" (hi) \

: "cc")

#else /* ! __thumb__ */

# define MAD_F_MLN(hi, lo) \

asm ("rsbs %0, %2, #0\n\t" \

"rsc %1, %3, #0" \

: "=r" (lo), "=r" (hi) \

: "=&r" (lo), "=r" (hi) \

: "0" (lo), "1" (hi) \

: "cc")

#endif /* __thumb__ */


4.修改makefile文件,-fforce-mem去除   然后$sudo make

5.$make install


   二、 交叉编译zlib

    官网下载zlib库,我使用的版本为:zlib-1.2.8.tar.gz

    首先声明,网上很多文章写的步骤是:先指定编译器 $export CC=arm-linux-gnu-gcc,然后配置、编译,我每次编译的结果都是X86的库,后来参考(http://bbs.csdn.net/topics/380264732)一文,找到了正确的方法:

   1.配置$./configure -shared --prefix=/usr/local/zlib-arm

   2.修改makefile文件,修改如下:

-CC=gcc

+CC=arm-linux-gcc

 

 CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1

 #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7

@@ -27,8 +27,8 @@

 SFLAGS=-O3 -fPIC -D_LARGEFILE64_SOURCE=1

 LDFLAGS= -L. libz.a

 TEST_LDFLAGS=-L. libz.a

-LDSHARED=gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map

-CPP=gcc -E

+LDSHARED=arm-linux-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map

+CPP=arm-linux-gcc -E

 

 STATICLIB=libz.a

 SHAREDLIB=libz.so

@@ -36,8 +36,8 @@

 SHAREDLIBM=libz.so.1

 LIBS=$(STATICLIB) $(SHAREDLIBV)

 

-AR=ar rc

-RANLIB=ranlib

+AR=arm-linux-ar rc

+RANLIB=arm-linux-ranlib

 LDCONFIG=ldconfig

 LDSHAREDLIBC=-lc

 TAR=tar


3.然后$sudo make

4.$make install


 三、 交叉编译mplayer

1.配置$sudo ./configure --host-cc=gcc --cc=/opt/gcc-linaro-arm-linux-gnueabihf-4.9/bin/arm-linux-gnueabihf-gcc --target=arm-linux --enable-fbdev --enable-static --disable-dvdread --disable-live  --enable-mad --disable-win32dll --disable-mencoder --disable-ivtv --disable-dvdnav  --prefix=/home/mplayer11 --extra-ldflags="-L/home/zgd/lib" --extra-cflags="-I/home/zgd/include"  --disable-mp3lib --enable-mad 2>&1 | tee logfile 
注意:前面生成的lib文件和include文件统一放一起,然后配置--extra-ldflags=和--extra-cflags=,否则会找不到库文件而报错

2.$sudo make,之后make install会报错,所以不用make install了,直接拷贝到开发板上就能用了


按此方法可以编译mplayer1.1和mplayer1.3,但是编译MPlayer-1.0rc4会报错,还没时间去弄明白什么原因。。。。。