1、环境
linux操作系统:fedora 10;
交叉编译器: arm-linux-gcc-4.3.3
目前madplay的官方网站是http://www.underbit.com/products/mad/,透过该网
站的介绍可以得知, 它还需要libmad 和libid3tag 两个库, 从该网站找到下载
连接http://sourceforge.net/project/showfiles.php?group_id=12349
这样我们就得到了移植 madplay
madplay-0.15.2b.tar.gz
libmad-0.15.1b.tar.gz
libid3tag-0.15.1b.tar.gz
2、手动编译
#mkdir madplay
#cd madplay
#mkdir tarball src-x86 src-arm target-x86 target-arm
目录说明:
tarball 目录用来存放所有的源代码包
src-x86
src-arm
target-x86 目录是X86 版本的安装目录
target-arm
接下来把从网上下载到的源代码包放入 tarball
解压源代码包
#cd tarball
#for f in $(ls *.tar.gz); do tar xvzf $f –C ../src-x86; done
编译madplay
a) libid3tag
#cd ../src-x86/libid3tag-0.15.1b
#./configure --prefix=/opt/GTStudio/GT2440/madplay/target-x86
#make
#make install
b) libmad
#cd ../libmad-0.15.1b
#./configure --prefix=/opt/GTStudio/GT2440/madplay/target-x86
#make
#make install
以上过程完毕,将在 target-x86
文件。
编译安装madplay
提示我们在配置 madplay
装了依赖库,根据提示我们要设置CPPFLAGS
置:
CPPFLAGS=-I//opt/GTStudio/GT2440/madplay/target-x86/include
提示告诉我们还要设置 LDFLAGS 环境变量,因此再次修改配置参数如下:
CPPFLAGS=-I/opt/GTStudio/GT2440/madplay/target-x86/include
LDFLAGS=-L/opt/GTStudio/GT2440/madplay/target-x86/lib
这说明配置已经成功,生成了编译所需要的 Makefile 文件,输入一下命令
开始编译安装:
/opt/GTStudio/GT2440/madplay/target-x86 目录中:
其中abxtest
测试PC 版的madplay
如果你的声卡已经正确安装,就可以听到mp3 的声音了。
3、构建编译脚本build-x86
[root@HeBi madplay]# cat build-x86
#!/bin/sh
MADPLAY_DIR=$PWD
SRC_DIR=src-x86
TARGET_DIR=$MADPLAY_DIR/target-x86
#tar xvzf ./tarball/libid3tag-0.15.1b.tar.gz -C$SRC_DIR
#tar xvzf ./tarball/libmad-0.15.1b.tar.gz -C $SRC_DIR
#tar xvzf ./tarball/madplay-0.15.2b.tar.gz -C $SRC_DIR
cd $SRC_DIR/libid3tag-0.15.1b
./configure --prefix=$TARGET_DIR
make;make install
cd ../../
cd $SRC_DIR/libmad-0.15.1b
./configure --prefix=$TARGET_DIR
make;make install
cd ../..
cd $SRC_DIR/madplay-0.15.2b
./configure --prefix=$TARGET_DIR CPPFLAGS=-I$TARGET_DIR/includeLDFLAGS=-L$TARGET_DIR/lib
make;make install
cd ../../
[root@HeBi madplay]#
在安装过程中会出现错误:
cc1: error: unrecognized command line option "-fforce-mem"
make[2]: *** [version.lo] 错误 1
make[2]: Leaving directory`/opt/GTStudio/GT2440/madplay/src-x86/libmad-0.15.1b'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory`/opt/GTStudio/GT2440/madplay/src-x86/libmad-0.15.1b'
make: *** [all] 错误 2
make
configure: error: mad.h was not found
*** You must first install libmad before you can build thispackage.
*** If libmad is already installed, you may need to use theCPPFLAGS
*** environment variable to specify its installed location, e.g.-I
解决办法:
[root@HeBi madplay]# ls
build-arm
[root@HeBi madplay]# cd src-x86/
[root@HeBi src-x86]# ls
libid3tag-0.15.1b
[root@HeBi src-x86]# cd libmad-0.15.1b/
[root@HeBi libmad-0.15.1b]# ls
aclocal.m4
bit.c
bit.h
CHANGES
config.guess
config.h
config.h.in
config.log