ARM上交叉编译蓝牙Bluez


应好友的求助,帮忙编译bluez
我的机器环境 Ubuntu 10.04
arm-none-linux-gnueabi-gcc  4.3.3

源码下载的地方:
http://pkgs.fedoraproject.org/repo/pkgs/

dbus-1.2.16.tar.gz  download

Bluez交叉编译移植到arm linux .
Version:

Bluez:3.36

Gcc :arm-linux-gcc-3.4.1

所需软件包:

libxml2-2.7.4

dbus1.0.2

glib-2.16.5

bluez-utils-3.36依赖于dbus和glib,而dbus依赖于libxml2,所以编译顺序是libxml,dbus,glib,bluez-utils-3.36.

流程写的简单,其实在我自己的编译过程中出现了无数的问题,只是都简化到配置里面去了,所以configuare一定要配置好.

1.编译bluez-libs-3.36

./configure --host=arm-linux --prefix="$PWD/../release/bluez_libs"
make&make install
没有什么依赖库的问题,直接编译通过.

2.编译libxml2-2.7.4

./configure --prefix="$PWD/../release/bluez_libs" --host=arm-linux
  make
  make install

没有依赖库,顺利通过

3.编译dbus1.0.2

echo ac_cv_have_abstract_sockets=yes>arm-linux.cache
./configure --prefix="$PWD/../release/bluez_libs" --host=arm-linux CC="arm-linux-gcc -I/home/jay/tools/bluez3/release/bluez_libs/include -L/home/jay/tools/bluez3/release/bluez_libs/lib" --cache-file=arm-linux.cache --with-x=no
 --with-xml=libxml PKG_CONFIG_PATH="$PWD/../release/bluez_libs/lib/pkgconfig"
make&make install
顺利通过了

4.编译glib-2.16.5

echo ac_cv_type_long_long=yes>arm-linux.cache
echo glib_cv_stack_grows=no>>arm-linux.cache
echo glib_cv_uscore=no>>arm-linux.cache
echo ac_cv_func_posix_getgrgid_r=yes>>arm-linux.cache
echo ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cache
./configure --prefix="$PWD/../release/bluez_libs" --host=arm-linux CC="arm-linux-gcc -I/home/jay/tools/bluez3/release/bluez_libs/include
-L/home/jay/tools/bluez3/release/bluez_libs/lib" --cache-file=arm-linux.cache PKG_CONFIG_PATH="$PWD/../release/bluez_libs/lib/pkgconfig"
#make
#make install

5.编译bluez-utils-3.36.
./configure --prefix="$PWD/../release/bluez_libs" --host=arm-linux CC="arm-linux-gcc -I/home/jay/tools/bluez3/release/bluez_libs/include -L/home/jay/tools/bluez3/release/bluez_libs/lib -shared" PKG_CONFIG_PATH="$PWD/../release/bluez_libs/lib/pkgconfig" --disable-audio --enable-test

make&make install

如果不追加-shared,会出现很讨厌的__fini_array_start错误.

遇到storage.c:286: error: error: `ENOKEY' undeclared
修改storage.c 增加#define ENOKEY 161

至此bluez编译完毕.


文件系统的制作:

将sbin和bin下的文件复制进文件系统的sbin下面,lib文件需要的有

libbluetooth.so
libbluetooth.so.2  libbluetooth.so.2.11.2

libxml2.so
libxml2.so.2 libxml2.so.2.7.4

libglib-2.0.so
libglib-2.0.so.0 libglib-2.0.so.0.1600.5

libgmodule-2.0.so.0  libgmodule-2.0.so.0.1600.5

前面是软链接,后面是本尊

将etc文件夹复制过去.

最后记得把hcidump(需要另外编译,没有任何难度)复制到sbin,它方便调试的

以下是Leeu我的编译遇到 的问题.

libusb 要用到g++
./configure --prefix=/opt/libs --host=arm-linux CC="arm-none-linux-gnueabi-gcc" CXX=arm-none-linux-gnueabi-g++  

dbus的编译,把下面整个一起执行

USE_ARCH=32 NM=nm CC="arm-none-linux-gnueabi-gcc ${BUILD32}" ./configure --prefix=/opt/libs --host=arm-linux --target=arm-linux     CC="arm-none-linux-gnueabi-gcc -I/opt/libs/include -L/opt/libs/lib" --cache-file=arm-linux.cache --with-x=no
否则会报libtool中 eval的错误

4.编译glib-2.16.5

echo ac_cv_type_long_long=yes>arm-linux.cache
echo glib_cv_stack_grows=no>>arm-linux.cache
echo glib_cv_uscore=no>>arm-linux.cache
echo ac_cv_func_posix_getgrgid_r=yes>>arm-linux.cache
echo ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cache


./configure --prefix=/opt/libs --host=arm-linux CC="arm-none-linux-gnueabi-gcc -I/opt/libs/include -L/opt/libs/lib" --cache-file=arm-linux.cache PKG_CONFIG_PATH=/opt/libs/lib/pkgconfig

#make
#make install

buluz-utils
./configure --prefix=/opt/libs --host=arm-linux CC="arm-none-linux-gnueabi-gcc -I/opt/libs/include -L/opt/libs/lib -shared" PKG_CONFIG_PATH=/opt/libs/lib/pkgconfig --disable-audio
去掉--enable-test
过程会报找不到yacc, flex等命令,安装命令即可

这样就编译好了。

相关内容