赞
踩
../src/.libs/libasound.so: undefined reference to `atomic_add'
atomic_sub在include/iatomic.h中定义,找了下有__arm__对应的版本,但是没有__mipsel__,只有__mips__,那就死马当活马了:
./configure --host=mips-linux --prefix=/home/cy/alsa/lib/ --enable-shared --disable-python
然后make,又是:
../src/.libs/libasound.so: undefined reference to `atomic_sub'
../src/.libs/libasound.so: undefined reference to `atomic_add
//extern __inline__ void atomic_add(int i, atomic_t * v)
//extern __inline__ void atomic_sub(int i, atomic_t * v)
将其中的函数实现的函数类型“extern ”改为“static”即可!
//static __inline__ void atomic_add(int i, atomic_t * v)
//static __inline__ void atomic_sub(int i, atomic_t * v)
alsa-lib-1.0.24.1配置编译
CC=/opt/buildroot-gcc342/bin/mipsel-linux-gcc ./configure --host=mipsel-linux --prefix=/opt/mips/alsa_lib/ --enable-shared --disable-python
alsa-utils-1.0.24.2配置编译
CC=/opt/buildroot-gcc342/bin/mipsel-linux-gcc ./configure --prefix=/opt/mips/alsa_utils/ --host=mips --with-alsa-prefix=/opt/mips/alsa_lib/lib_1.0.24.1/lib/ --with-alsa-inc-prefix=/opt/mips/alsa_lib/lib_1.0.24.1/include/
./configure --prefix=/home/armmlinux/zdfwork/project/audio/alsa/output/mips-linux AR=/opt/buildroot-gcc342/bin/mipsel-linux-uclibc-ar CC=/opt/buildroot-gcc342/bin/mipsel-linux-uclibc-gcc CXX=/opt/buildroot-gcc342/bin/mipsel-linux-uclibc-g++ CXX=/opt/buildroot-gcc342/bin/mipsel-linux-uclibc-g++ --host=mipsel-linux-uclibc --enable-shared=yes --enable-static=no --target=mipsel-linux-uclibc --with-debug=no --with-alsa-devdir=/dev --with-softfloat --with-configdir=/usr/ LDFLAGS="-lm"
ALSA是目前Linux系统上大量采用的音频设备库,通过Alsa架构能分离驱动和应用的开发。Alsa为上层提供API的同时,也为下层提供了接口,在内核配置的时候指定“支持Alsa”就能得到内核支持,具体位置为:
Menuconfig -> Device Drivers -> Soundcard support -> Advanced Linux Sound Architecture
有了Alsa内核驱动,我们还需要Alsa Lib和Alsa Util的支持,这3者的关系如下图所示:
Alsa Util
-------------
Alsa lib
-------------
Alsa Driver
Alsa Util是纯应用层的软件,相当于Alsa设备的测试程序,AlsaLib则是支持应用API的中间层程序。移植Alsa程序的顺序就是先后移植Driver,Lib,Util。
ALSA下载主页:http://www.alsa-project.org/main/index.php/Download
一.Alsa Lib移植
1.编译alsa-lib:
cd /home/pingle/BackUp/alsa-tools/alsa-lib-1.0.15/
$ ./configure --prefix=/home/pingle/alsa/ AR=mipsel-openwrt-linux-uclibc-ar CC=mipsel-openwrt-linux-uclibc-gcc CXX=mipsel-openwrt-linux-uclibc-g++ CXX=mipsel-openwrt-linux-uclibc-g++ --host=mipsel-openwrt-linux-uclibc --enable-shared=yes --enable-static=no --target=mipsel-openwrt-linux-uclibc --with-debug=no --with-alsa-devdir=/dev --with-softfloat --with-configdir=/usr/local/share LDFLAGS="-lm"
make
make install
2.编译alsa-utils:
cd /home/pingle/BackUp/alsa-tools/alsa-utils-1.0.15/
./configure --prefix=/home/pingle/alsa/ AR=mipsel-openwrt-linux-uclibc-ar CC=mipsel-openwrt-linux-uclibc-gcc CXX=mipsel-openwrt-linux-uclibc-g++ CXX=mipsel-openwrt-linux-uclibc-g++ --host=mipsel-openwrt-linux-uclibc CPPFLAGS="-I/home/pingle/alsa/include" LDFLAGS="-L/home/pingle/alsa/lib" --disable-alsamixer
make
make install
1)--host指定编译器,这里指定为在目标板所运行的交叉编译器。注意运行本配置命令前务必保证编译器已经可以在Shell下直接执行了。
2)--prefix指定编译后文件的安装路径,后续的安装命令会在该目录中创建lib和include两个目录
3)若编译make install时报错:"mipsel-linux-ranlib command not found",解决方案为:执行make install之前,先用下su命令取得root权限。然后再执行make install
二.lib和util安装到嵌入式平台
在目标板上,以下文件必须被拷贝至对应位置
1) lib库文件,放在 /lib/中
2) conf文件,应放在/usr/local/share中,与编译时指定的目录相同3) 应用文件,util能产生aplay,amixer,arecord可执行程序,这些文件可放在/usr/sbin中
4) 必须保证有/dev/snd/目录中,此目录下应包含以下几个设备文件(驱动),controlC0, pcmC0D0c, pcmC0D0p, timer如果这些文件已经在/dev/下,可拷贝到snd目录中。或者建立相应符号链接,
ln -s /dev/pcmC0D0c /dev/snd/pcmC0D0c
ln -s /dev/controlC0 /dev/snd/controlC0
ln -s /dev/timer /dev/snd/timer
三.运行测试程序
export ALSA_CONFIG_PATH=/usr/share/alsa/alsa.conf
未添加环境变量前出现的错误:
~ # ./aplay
ALSA lib conf.c:2827:(snd_config_hook_load) cannot access file /usr/share/arm-alsa/share/alsa/cards/aliases.conf
ALSA lib pcm.c:1959:(snd_pcm_open_conf) Invalid type for PCM default definition (id: default, value: cards.pcm.default)
aplay: main:533: audio open error: Invalid argument
~ # ./aplay
ALSA lib pcm.c:2090:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:533: audio open error: No such file or directory
编译报错:can't load library 'libpthread.so.0'。
解决方案:在openwrt中的make menuconfig中加入libpthread支持。
编译报错:fatal error: alsa/asoundlib.h: No such file or directory compilation terminated.
解决方案:mipsel-openwrt-linux-uclibc-gcc -lasound -L/home/pingle/alsa/lib -I/home/pingle/alsa/include -o test_audio2 test_audio02.c
四.回顾驱动程序
在/home/pingle/kernal/ws04/build_dir/target-mipsel_uClibc-0.9.32/root-xburst目录下加入自己的文件;
然后:
$cd /home/pingle/Yaff/linux-2.6.24.3/fs/yaffs2/utils
(可能要make一下哦!)
$./mkyaffs2image 1 /home/pingle/kernal/ws04/build_dir/target-mipsel_uClibc-0.9.32/root-xburst /home/pingle/desktop/xburst-tools-ws10/image/rootfs.yaffs2(参数) (rootfs的目录) (生成的文件yaffs系统存到的目录)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。