Chinaunix首页 | 论坛 | 博客
  • 博客访问: 580522
  • 博文数量: 192
  • 博客积分: 3780
  • 博客等级: 中校
  • 技术积分: 1487
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-26 10:11
文章存档

2012年(6)

2011年(160)

2010年(26)

分类: 嵌入式

2011-05-09 21:47:53


mp3播放器madplay移植过程详解


一、在PC机上编译测试


错误1

cc1: error: unrecognized command line option “-fforce-mem”
 
在我编译安装的时候出现下面的错误
cc1: error: unrecognized command line option “-fforce-mem”
其实这个错误是编译安装libmad时候引起的,audacity包含libmad

解决方式是:找到libmad configure之后的Makefile,

vi Makefile

找到包含"-fforce-mem"字符串,将其删除,就ok

原因是gcc 3.4 或者更高版本,已经将其去除了,所以会出现上面的错误!

Compiling libmad with gcc 3.4 or higher will produce the following error: cc1: error: unrecognized command line option “-fforce-mem”. The build option “-fforce-mem” has been kicked out of gcc, so you need to alter the makefile (just vi Makefile after you have configured, hit “/” to search for the entry and delete it)


http://dev.firnow.com/course/6_system/linux/Linuxjs/20100520/202817.html


错误2:缺少zlib,安装之

derek@derek-virtual-machine:~/mini2440/madplay/src-x86/madplay-0.15.0b$ sudo aptitude install zlib1g-dev


http://www.cnblogs.com/lling1105/archive/2008/01/03/1024104.html


错误3:缺少mad.h头文件,加上之,注意加上CPPFLAGS标志-I

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

.

derek@derek-virtual-machine:~/mini2440/madplay/src-x86/madplay-0.15.0b$ ./configure --prefix=/home/derek/mini2440/madplay/target-x86/ CPPFLAGS=-I/home/derek/mini2440/madplay/target-x86/include



错误4:缺少libmad文件,加上之,注意加上LDFLAGS 标志-L

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

.

derek@derek-virtual-machine:~/mini2440/madplay/src-x86/madplay-0.15.0b$ ./configure --prefix=/home/derek/mini2440/madplay/target-x86/ CPPFLAGS=-I/home/derek/mini2440/madplay/target-x86/include LDFLAGS=-L/home/derek/mini2440/madplay/target-x86/lib


checking for gcc... gcc

checking for C compiler default output... configure: error: C compiler cannot create executables

See `config.log' for more details.

derek@derek-virtual-machine:~/mini2440/madplay/src-x86/madplay-0.15.0b$ sudo apt-get install build-essential g++


二、往arm目标机移植


错误1

checking zlib.h usability... no

checking zlib.h presence... no

checking for zlib.h... no

configure: error: zlib.h 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 CPPFLAGS

*** environment variable to specify its installed location, e.g. -I

.


下载zlib-1.2.5.tar.gz解压,然后执行export CC=arm-linux-gcc,这个很重要,这样后面的在当前的shell中的默认都是arm-linux-gcc编译了

执行 export $CC 确认一下

zlib目录下执行,

./configure --prefix=/home/derek/mini2440/madplay/target-arm

make && make install

zlib安装成功



libid3tag目录下执行,libid3tag依赖与zlib

./configure --host=arm-linux –prefix=/home/derek/mini2440/madplay/target-arm

如果还出现上述错误,则显示指定CPPFLAGS LDFLAGS ,如下;

./configure --host=arm-linux --prefix=/home/derek/mini2440/madplay/target-arm CPPFLAGS=-I/home/derek/mini2440/madplay/target-arm/include LDFLAGS=-L/home/derek/mini2440/madplay/target-arm/lib

make && make install

libid3tag安装成功


libmad目录下执行,

./configure --host=arm-linux –prefix=/home/derek/mini2440/madplay/target-arm

make && make install

libmad安装成功



madplay目录下执行,

./configure --host=arm-linux --prefix=/home/derek/mini2440/madplay/target-arm CPPFLAGS=-I/home/derek/mini2440/madplay/target-arm/include LDFLAGS=-L/home/derek/mini2440/madplay/target-arm/lib

make && make install

madplay安装成功



target-arm目录下执行,打包,通过上传至目标板:

tar cvzf target-arm.tar.gz target-arm/

ftp 192.168.1.230


然后将bin下的madplay重命名放到/usr/bin目录下

在将lib下的所有库放到/usr/lib目录下



三、也可以参考如下两片文章的做法:


http://blog.chinaunix.net/space.php?uid=23089249&do=blog&cuid=2139514


目标板     :博创2410s
编译器     :arm-linux-gcc-3.4.1

    


编译步骤:
1.
移植madplay前的准备。
madplay
的移植需要以下的几个包:
1madplay-0.15.2b.tar.gz
2libmad-0.15.1b.tar.gz
3libid3tag-0.15.1b.tar.gz
4zlib-1.1.4.tar.gz
其中前面三个包可以在下载,后一个包可以在中找到。
为了编译这个播放器,还需要一个交叉编译器,我用的是arm-linux-gcc 3.4.1版本。
下载地址:

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可执行文件下载到板子上测试,输入
/tmp/madplayer/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
则是因为在编译时没有设置好静态链接和共享库,正确的配置就是在编译,libid3taglibmad madplay 时,加上disable-shared 选项,同时在madplay 的配置语句上加上enable-static设置为静态。



http://blog.mcuol.com/User/allenwoo/article/6754_1.htm



又是一篇公司技术文档啦!

如你们看了我的技术文档,去Genny杭州半导体面试或许很有优势哦

 

 

移植madplay 需要如下文件:madplay-b.tar.gzlibmad-0.15.1b.tar.gzlibid3tag-0.15.1b.tar.gz zlib-1.2.3.tar.gz

这里列出它们的下载地址:前三个文件的下载地址在这个网站可以找到相应的链接:

zlib-.tar.gz (zlib-1.2.3.tar.gz类似)的下载地址为:

1、配置编译环境

我们使用的是装有VmwareRedHat开发环境,交叉编译器放/usr/local/arm-uclinux-tools/bin/目录下的。首先在根目录下面建立了一个名为“madplayer的目录,然后把四个gz都解压到这个目录下面,同时还建立了一个名为“libz的目录,作为存放所生成的文件的地方,总共在/madplayer目录下,有5 个目录。

[root@localhost madplayer]# ls                                                        

libid3tag-b  libmad-0.15.1b  libz  madplay-0.15.2b  zlib-1.2.3                                                     

[root@localhost madplayer]#                                                     

2 编译zlib-

首先配置configure 文件,改动如下:

u     AR=${AR-" ar rc"}改为:

AR=${AR-"/usr/local/arm-uclinux-tools/bin/arm-uclinux-elf-ar rcs"}

u     RANLIB=${RANLIB-"ranlib"}改为:

RANLIB=${RANLIB-"/usr/local/arm-uclinux-tools/bin/arm-uclinux-elf-ranlib"}

u     cc=${CC-gcc}改为:

cc=${CC-/usr/local/arm-uclinux-tools/bin/arm-uclinux-elf -gcc}

u     然后保存它,使用如下指令编译:

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

然后输入:./configure --prefix=/root/madplayer/libz

待上步完成后,输入:make

然后再输入:make install

到此,编译zlib- 就算完成了。

3 编译libid3tag-b

在完成zlib- 的编译后,才能进行libid3tag-0.15.1b 的编译。

配置Makefile

CC=/usr/local/arm-uclinux-tools/bin/arm-uclinux-elf-gcc ./configure --host=arm-uclinux-elf --prefix=/root/madplayer/libz --disable-shared CPPFLAGS=-I/root/madplayer/libz/include

LDFLAGS=-L/root/madplayer/libz/lib

然后使用:make

最后使用:make install 完成libid3tag-b 的编译。

4 编译libmad-b

配置Makefile

CC=/usr/local/arm-uclinux-tools/bin/arm-uclinux-elf-gcc ./configure

--host=arm-uclinux-elf --prefix=/root/madplayer/libz –disable-shared

然后使用:make,生成所需的库文件;

最后使用:make install 完成libmad-b 的编译。

5 编译madplay-b

配置Makefile

CC=/usr/local/arm-uclinux-tools/bin/arm-uclinux-elf-gcc ./configure --host=arm-uclinux-elf --prefix=/root/madplayer/libz --disable-shared --enable-static CPPFLAGS=-I/root/madplayer/libz/include

LDFLAGS=-L/root/madplayer/libz/lib

然后使用:make,最后在madplay-b 目录下面生成大小为617KB madplay的可执行文件。

6 然收把madplay的可执行文件放到romfsbin目录下,用genromfs工具形成romfs.img文件,烧到开发板。就可以正常的播放MP3 歌曲了。

缺省格式:madplay /yourname/*.mp3

7 编译中,可能遇到的问题:

u     如果出现这样的错误提示:

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 导致的,如果要正确配置,参考步骤2

u     最后编译出来的mdaplay 在开发板上运行时出现如下所示的提示:

madplay: error while loading shared libraries: cannot open shared object file: cannot load sharedobject file: No such file or directory

则是因为在编译时没有设置好静态链接和共享库,正确的配置就是在编译,libid3taglibmad madplay 时,加上disable-shared 选项,同时在madplay 的配置语句上加上enable-static设置为静态。

总结:关于madplayer播放器,虽然MAD is a high-quality MPEG audio decoder,支持MPEG-1,MPEG-2, All three audio layers— Layer I, Layer II, and Layer III (i.e. MP3),但是,由于其强大的功能,带来的是占用较大资源。另外,基于ARM7TFMI的音频处理器(GE9008)是否有足够快速强大的运算能力也是个问题。


阅读(3487) | 评论(0) | 转发(2) |
0

上一篇:Android AppWidget实例验证

下一篇:Xmodem协议

给主人留下些什么吧!~~