Linux 2.6.22.19移植到S3C2410(博创2410s)之:madplay移植


1. 移植madplay前的准备。
madplay的移植需要以下的几个包:
(1)madplay-0.15.2b.tar.gz,
(2)libmad-0.15.1b.tar.gz,
(3)libid3tag-0.15.1b.tar.gz ,
(4) zlib-1.1.4.tar.gz。
其中前面的三个包可以在http://sourceforge.net/project/showfiles.php?group_id=12349下载,后一个包可以在http://www.gzip.org/zlib/zlib-1.1.4.tar.gz中找到。
为了编译这个播放器,还需要一个交叉编译器,我用的是arm-linux-gcc 3.4.1版本。
下载地址:http://www.handhelds.org/download/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2

2. 建立了一个名为“madplayer”的目录,我的madplayer目录为/arm2410s/madplayer。然后把四个gz都移动到这个目录下,解压并改名,同时还建立了一个名为“libz”的目录,作为库目录。
[root@localhost madplayer]# tar zxvf madplay-0.15.2b.tar.gz
[root@localhost madplayer]# mv madplay-0.15.2b madplay
[root@localhost madplayer]# tar zxvf libmad-0.15.1b.tar.gz
[root@localhost madplayer]# mv libmad-0.15.1b libmad  
[root@localhost madplayer]# tar zxvf libid3tag-0.15.1b.tar.gz
[root@localhost madplayer]# mv libid3tag-0.15.1b libid3tag
[root@localhost madplayer]# tar zxvf zlib-1.1.4.tar.gz
[root@localhost madplayer]# mv zlib-1.1.4 zlib
[root@localhost madplayer]# mkdir libz
                                                                                      

3. 编译zlib-1.1.4(编译libid3tag需要用到)
   先输入./configure --prefix=/arm2410s/madplayer/libz。生成Makefile文件,
[root@localhost madplayer]# cd zlib
[root@localhost zlib]# ./configure --prefix=/arm2410s/madplayer/libz
[root@localhost zlib]# vi Makefile
   再修改(不能跟上面的步骤调转)makefile文件:
   CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc
   AR=/usr/local/arm/3.4.1/bin/arm-linux-ar rcs
   RANLIB=/usr/local/arm/3.4.1/bin/arm-linux-ranlib

注: 如果之前编译过,则先要把上次编译的结果清除:make distclean

接着make
然后make install
[root@localhost zlib]# make
[root@localhost zlib]# make install
编译好之后就可以在上面prefix指定的目录下的lib目录下找到libz.a这个库。

4. 编译libid3tag

[root@localhost zlib]# cd ../libid3tag
[root@localhost libid3tag]# ./configure CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc --prefix=/arm2410s/madplayer/libz --host=arm-linux --disable-shared CPPFLAGS=-I/arm2410s/madplayer/libz/include LDFLAGS=-L/arm2410s/madplayer/libz/lib
[root@localhost libid3tag]# make
[root@localhost libid3tag]# make install

5. 编译libmad
[root@localhost libid3tag]# cd ../libid3tag
[root@localhost libmad]# ./configure CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc --prefix=/arm2410s/madplayer/libz --host=arm-linux --disable-shared CPPFLAGS=-I/arm2410s/madplayer/libz/include LDFLAGS=-L/arm2410s/madplayer/libz/lib
[root@localhost libmad]# make
[root@localhost libmad]# make install


6. 编译madplay
[root@localhost libmad]# cd ../madplay
[root@localhost madplay]# ./configure CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc --prefix=/arm2410s/madplayer/libz --host=arm-linux --disable-shared --enable-static CPPFLAGS=-I/arm2410s/madplayer/libz/include LDFLAGS=-L/arm2410s/madplayer/libz/lib
然后,make,生成了madplay可执行文件
[root@localhost madplay]# make

7.把madplay可执行文件下载到板子上测试,输入
[root@localhost madplay]# ./madplay NewDivide.mp3
美妙的歌曲荡漾耳边

注意,要想听到音乐,你得确保你已经安装了声卡驱动,否则你会出现类似以下的错误提示:
PEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
audio: /dev/dsp: No such file or directory

编译中,可能遇到的问题:
如果出现这样的错误提示:
error: libz was not found
*** You must first install zlib (libz) before you can build this package.
*** If zlib is already installed, you may need to use the LDFLAGS
*** environment variable to specify its installed location, e.g. -L.
则是没有正确配置编译好zlib 导致的,如果要正确配置,参考步骤3。

最后编译出来的mdaplay 在开发板上运行时出现如下所示的提示:
madplay: error while loading shared libraries: cannot open shared object file: cannot load sharedobject file: No such file or directory
则是因为在编译时没有设置好静态链接和共享库,正确的配置就是在编译,libid3tag、libmad 和madplay 时,加上disable-shared 选项,同时在madplay 的配置语句上加上enable-static设置为静态。

 

你可能感兴趣的:(c,linux,File,makefile,audio,编译器)