libmad编译移植到A20

来源:互联网 发布:域名续费怎么收费 编辑:程序博客网 时间:2024/04/25 01:30

第一次写博客和大家分享劳动成果,如果写得不好请大家海涵

我用的平台是蜂鸟开发板(全志A20)。

在网上下载的libmad-0.15.1b.tar.gz,百度一搜一大把,我就不提供链接了。

解压后执行:

./configure --host=arm-linux-gnueabihf --prefix=/usr/local/libmad_arm --enable-shared --enable-static --enable-fpm=arm --with-gnu-ld=arm-linux-gnueabihf-ld --build=arm

然后

  make

出现错误:

cc1: error: unrecognized command line option “-fforce-mem”

原因是高版本的gcc,已经将-fforce-mem去除了,解决方法:

sed -i '/-fforce-mem/d' configure
再执行:

./configure --host=arm-linux-gnueabihf --prefix=/usr/local/libmad_arm --enable-shared --enable-static --enable-fpm=arm --with-gnu-ld=arm-linux-gnueabihf-ld --build=arm

出现错误:

/tmp/ccf2FxyW.s:1299: Error: selected processor does not support Thumb mode `rsc r0,r0,#0'
/tmp/ccf2FxyW.s:1435: Error: selected processor does not support Thumb mode `rsc r8,r8,#0'
/tmp/ccf2FxyW.s:1857: Error: selected processor does not support Thumb mode `rsc r0,r0,#0'
/tmp/ccf2FxyW.s:1996: Error: selected processor does not support Thumb mode `rsc r0,r0,#0

百度一下发现这是libmad的一个bug.

解决方法是:

vim  fixed.h

#  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__ */

再make,编译通过了!

然后

make install

编译成功,在/usr/local/libmad_arm下生成了库。

可用jwzhangjie大牛的mp3解码播放程序http://blog.csdn.net/jwzhangjie/article/details/9209807测试,前提是你已经移植了libsalsa哈。我测试时发现打不开"plughw:0,0",然后我改为"default"就OK了。

然后又出现找不到ld-linux-armhf.so.3库,是linux下进行动态库连接的连接器。而我的交叉编译工具下的连接器是ld-2.11.1.so,还有一个是链接ld-linux.so.3,于是我再弄个链接ln -s ld-2.11.1.so ld-linux-armhf.so.3。编译成功。

将libmad.so.0移植到开发板的/lib, 再弄个链接ln -s ld-2.11.1.so ld-linux-armhf.so.3。

然后就可用运行mp3解码播放程序了。



0 0
原创粉丝点击