首先下载需要的源码,此次编译需要用到3个lib库,
分别是libaudiofile.so库,libesd.so库和libao.so库,以下所有编译基于arm-linux-gcc-4.3.2
luther@gliethttp:/vobs/mpg123$ wget
luther@gliethttp:/vobs/mpg123$ wget
luther@gliethttp:/vobs/mpg123$ wget
luther@gliethttp:/vobs/mpg123$ wget
1.交叉编译libaudiofile.so库
luther@gliethttp:/vobs/mpg123/audiofile-0.2.6$ ./configure --host=arm-linux --prefix=/home/luther/gliethttp
luther@gliethttp:/vobs/mpg123/audiofile-0.2.6$ make -j4
luther@gliethttp:/vobs/mpg123/audiofile-0.2.6$ tree ~/gliethttp
/home/luther/gliethttp
|-- bin
| |-- audiofile-config
| |-- sfconvert
| `-- sfinfo
|-- include
| |-- af_vfs.h
| |-- audiofile.h
| `-- aupvlist.h
|-- lib
| |-- libaudiofile.a
| |-- libaudiofile.la
| |-- libaudiofile.so -> libaudiofile.so.0.0.2
| |-- libaudiofile.so.0 -> libaudiofile.so.0.0.2
| |-- libaudiofile.so.0.0.2
| `-- pkgconfig
| `-- audiofile.pc
`-- share
`-- aclocal
`-- audiofile.m4
6 directories, 13 files
luther@gliethttp:/vobs/mpg123/audiofile-0.2.6$ sudo cp -a ~/gliethttp/lib/* /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/
2.交叉编译libesd.so库
luther@gliethttp:/vobs/mpg123/esound-0.2.41$ cp ~/gliethttp/include/* .
luther@gliethttp:/vobs/mpg123/esound-0.2.41$ ./configure --host=arm-linux --prefix=/home/luther/gliethttp
luther@gliethttp:/vobs/mpg123/esound-0.2.41$ make -j4
luther@gliethttp:/vobs/mpg123/esound-0.2.41$ make install
luther@gliethttp:/vobs/mpg123/esound-0.2.41$ sudo cp -a ~/gliethttp/lib/* /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/
3.交叉编译libao.so库
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ vim configure
1.将732行的空格换为'-'连接符
PACKAGE_STRING='libao-0.8.8'
2.注释掉20216行
cat >>confdefs.h <<_ACEOF
// #define DLOPEN_FLAG $DLOPEN_FLAG
_ACEOF
以上的2处改动不会对结果产生任何影响(已经使用vbindfiff比较了2次结果)[luther.gliethttp]
//===========================================================================
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ gcc -v
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ arm-linux-gcc -v
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72)
可能是Sourcery G++ 4.3.2的bug,直接使用./configure生成出来的Makefile包含2个如下带空格的宏定义,
-DPACKAGE_STRING=\"libao\ 0.8.8\"
-DDLOPEN_FLAG=\(RTLD_NOW\ \|\ RTLD_GLOBAL\)
使用gcc编译是没有问题的,但是使用arm-linux-gcc编译时,就提示:
arm-none-linux-gnueabi-gcc: 0.8.8": No such file or directory
arm-none-linux-gnueabi-gcc: |: No such file or directory
arm-none-linux-gnueabi-gcc: RTLD_GLOBAL): No such file or directory
: warning: missing terminating " character
可以看出来arm-linux-gcc将空格认为了数据分割符号,
跟踪之后发现只有
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ find . -name '*.c' -o -name '*.h' |xargs grep -nr DLOPEN_FLAG
./src/audio_out.c:38:#undef DLOPEN_FLAG
./src/audio_out.c:39:#define DLOPEN_FLAG 0
./src/audio_out.c:122: handle = dlopen(plugin_file, DLOPEN_FLAG /* See ao_private.h */);
./src/ao_private.h:42: * already defined DLOPEN_FLAG if the default is unacceptable on the
./src/ao_private.h:47:#if !defined(DLOPEN_FLAG)
./src/ao_private.h:48:#define DLOPEN_FLAG (RTLD_NOW | RTLD_GLOBAL)
所以会在./src/ao_private.h中自动添加
#if !defined(DLOPEN_FLAG)
#define DLOPEN_FLAG (RTLD_NOW | RTLD_GLOBAL)
#endif
所以直接去掉这个追加即可
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ vbindiff src/.libs/libao.so.2.1.3 ~/libao.so.2.1.3
//===========================================================================
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ cp ~/gliethttp/include/* include/
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ ./configure --host=arm-linux --prefix=/home/luther/gliethttp
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ make -j4
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ make install
luther@gliethttp:/vobs/mpg123/libao-0.8.8$ sudo cp -a ~/gliethttp/lib/* /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/
4.交叉编译mpg321播放器
luther@gliethttp:/vobs/mpg123/mpg321$ ./configure --host=arm-linux --prefix=/home/luther/gliethttp
luther@gliethttp:/vobs/mpg123/mpg321$ vim config.h
注释掉第201行的内容
// #define malloc rpl_malloc
luther@gliethttp:/vobs/mpg123/mpg321$ make -j4
luther@gliethttp:/vobs/mpg123/mpg321$ make install
luther@gliethttp:/vobs/mpg123/mpg321$ ll ~/gliethttp/bin/mpg321
-rwxr-xr-x 1 luther luther 125K 2009-08-13 15:24 /home/luther/gliethttp/bin/mpg321
luther@gliethttp:/vobs/mpg123/mpg321$ file ~/gliethttp/bin/mpg321
/home/luther/gliethttp/bin/mpg321: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, dynamically linked (uses shared libs), not stripped
好了大功告成了,因为开发板上的音频驱动还在进行中,所以不能在开发板上测试,
只是在qemu-system-arm模拟器中可以正常运行[luther.gliethttp]
此次编译得到的库包含如下:
luther@gliethttp:/vobs/mpg123/mpg321$ tree ~/gliethttp/lib
/home/luther/gliethttp/lib
|-- ao
| `-- plugins-2
| |-- libesd.la
| |-- libesd.so
| |-- liboss.la
| `-- liboss.so
|-- libao.la
|-- libao.so -> libao.so.2.1.3
|-- libao.so.2 -> libao.so.2.1.3
|-- libao.so.2.1.3
|-- libaudiofile.a
|-- libaudiofile.la
|-- libaudiofile.so -> libaudiofile.so.0.0.2
|-- libaudiofile.so.0 -> libaudiofile.so.0.0.2
|-- libaudiofile.so.0.0.2
|-- libesd.a
|-- libesd.la
|-- libesd.so -> libesd.so.0.2.39
|-- libesd.so.0 -> libesd.so.0.2.39
|-- libesd.so.0.2.39
|-- libesddsp.a
|-- libesddsp.la
|-- libesddsp.so -> libesddsp.so.0.2.39
|-- libesddsp.so.0 -> libesddsp.so.0.2.39
|-- libesddsp.so.0.2.39
`-- pkgconfig
|-- ao.pc
|-- audiofile.pc
`-- esound.pc
3 directories, 26 files
阅读(752) | 评论(0) | 转发(0) |