*********************************************************************
**实验目标:madplay 的移植
**日期:2012/12/16
**执行人:ToraLoo
*********************************************************************
tool version:
arm-linux-gcc 4.3.3
Ubuntu 12.04
GT2440 ARM9开发板
software version:
libid3tag-0.15.1b.tar.gz
libmad-0.15.1b.tar.gz
zlib-1.2.3.tar.gz
madplay-0.15.1b.tar.gz
====================================================================
1. 首先建立移植目录树
一般结构如下:
---madplay
|------tarball (存放库源码压缩包目录)
|------src-arm (存放解压后用于arm平台移植源码目录)
|------src-x86 (存放解压后用于x86平台源码目录)
|------target-arm (存放arm平台编译完成文件目录)
|------target-x86 (存放x86平台编译完成文件目录)
=====================================================================
2. 解压库源码包到madplay/src-arm下;
#cd ~/madplay/tarball
#tar zxvf libid3tag-0.15.1b.tar.gz -C ~/madplay/src-arm
#tar zxvf libmad-0.15.1b.tar.gz -C ~/madplay/src-arm
#tar zxvf zlib-1.2.3.tar.gz -C ~/madplay/src-arm
#tar zxvf madplay-0.15.2b.tar.gz -C ~/madplay/src-arm
====================================================================
3. 开始编译库
注意:每次configure之前请运行./configure --help(这是看了一个大神写的移植文档后开始学会这招的。)
===================================================================
a.) 移植zlib库
# cd libs/zlib-1.2.3/
#./configure --prefix=~/madplay/target-arm
生成Makefile,修改Makefile如下变量:
CC=arm-linux-gcc
AR=arm-linux-ar rcs
RANLIB=arm-linux-ranlib
保存退出,
#make
#make install
若发现目录设置有误,可使用make uninstall撤销安装,make distclean,make clean撤销编译
=============================================================================
b.)移植libid3tag
./configure --prefix=/arm/madplay/output/ --host=arm-linux --disable-debugging --disable-shared --enable-static CPPFLAGS=-I~/madplay/target-arm/include LDFLAGS=-L~/madplay/target-arm/lib
Make;
Make install;
============================================================================
c.) 移植libmad
===========================================================================
# ./configure --host=arm-linux --prefix=~/madplay/target-arm --disable-debugging --disable-shared --enable-static CPPFLAGS=-I/~/madplay/target-arm/include LDFLAGS=-L/~/madplay/target/lib
make后出现以下错误:
cc1: error: unrecognized command line option "-fforce-mem"
make[2]: *** [version.lo] Error 1
make[2]: Leaving directory `/arm/madplay/libs/libmad-0.15.1b''
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/arm/madplay/libs/libmad-0.15.1b''
make: *** [all] Error 2
=========================================================================
原因:编译器不支持该选项-fforce-mem
对策:查找Makefile中"fforce-mem", 将其删除,再试:
CFLAGS = -Wall -g -O -fforce-mem -fforce-addr -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -fexpensive-optimizations -fregmove -fschedule-insns2 -fstrength-reduce
在Makefile 129行,删除"-fforce-mem".
#make
#makeinstall
========================================================================
4. 开始编译madplay
========================================================================
./configure --prefix=~/madplay/target-arm/ --host=arm-linux
configure 出错:
configure: error: mad.h was not found
*** You must first install libmad before you can build this package.
*** If libmad is already installed, you may need to use the CPPFLAGS
*** environment variable to specify its installed location, e.g. -I
=======================================================================
原因:没有找到头文件
对策:加入头文件目录,修改CPPFLAGS参数,再试:
./configure --prefix=~/madplay/target-arm/ --host=arm-linux CPPFLAGS=-I~/madplay/target-arm/include
configure出错:
configure: error: libmad was not found
*** You must first install libmad before you can build this package.
*** If libmad is already installed, you may need to use the LDFLAGS
*** environment variable to specify its installed location, e.g. -L
=====================================================================
原因:没有找到库文件
对策:加入库文件目录,修改LDFLAGS参数,再试:
/configure --prefix=/arm/madplay/output/ --host=arm-linux --disable-debugging --disable-shared --enable-static CPPFLAGS=-I~/madplay/target-arm/include LDFLAGS=-L~/madplay/target-arm/lib
成 功生成Makefile
#make
#makefile
====================================================================
5. 测试:
./madplay For\ Fever\ Bor.mp3
如果不能运行,请检查:
a.)是否缺少动态链接库,并指定正确路径.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:(*.so路径)(此步骤可通过编译静态编译的版本来解决)
b.)arm-linux-gcc 版本是否与你的系统兼容.(一般会出现此类情况,也就是文件系统制作时使用的编译器以此版版本编译器不同造成的。)
c.)可执行文件是否损坏,如strip工具是否不是用的arm-linux-strip.
d.)编译器用错成X86平台的,可用#file madplay 确认一下.(这一步一定要进行,可明确你是否编译得到了想要平台的madplay)
===================================================================
注:如果参照上面每一步都确认无误的情况下,还出现如下错误信息:
checking for C compiler default output... configure: error: C compiler cannot create executables
See `config.log' for more details.
在网上找寻也很少人碰到此情况,有的网友碰到了选择的是重装gcc或g++等编译工具,有的则说是清空LIBS和LDFLAGS这两个环境变量,但是他们的解决方法主要针对的是x86下的情况;移植时使用的arm-linux-gcc也就表明了,不可能是上述的情况。最终搞到凌晨4:00左右还是不能解决,只能先睡再说。结果,第二点重启虚拟器再重新编译madplay-0.15.1b它又正常了。出现这种情况,应该是自己在编译过程中无意中修改了一些不应修改的环境变量造成的。
====================================================================
还有就是不太赞同,直接使用厂家编编写完成的shell脚本有进行移植,原因为:1、学习到的知识较少;2、出现错误不知在哪一个步骤出现,查错十分不便。