Chinaunix首页 | 论坛 | 博客
  • 博客访问: 323051
  • 博文数量: 41
  • 博客积分: 2540
  • 博客等级: 少校
  • 技术积分: 570
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-18 11:29
文章分类

全部博文(41)

文章存档

2011年(4)

2010年(32)

2009年(3)

2008年(2)

我的朋友

分类: 系统运维

2008-12-26 10:20:05

   前一段的时间,都在移植BlueZ的库文件和工具基到ARM的开发板,现在的整个一套设备已经基本完成。内核是开发板自己带的 2.6.13,从2.4.6后的版本里就已经在内核里带有了BlueZ支持,我要做的就是,进入Networking子项,build-in 上Bluetooth subsystem support。下面的L2CAP protocol support和SCO links support选中, Bluetooth device drivers里的是关于你使用USB蓝牙还是串口蓝牙,根据你的需要选择。 HCI VHCI (Virtual HCI device) driver是一个虚拟HCI接口,可以使你在没有蓝牙设备的使用,测试你的蓝牙应用程序,没有使用过。 保存退出,make。编译出新的内核镜像文件。

   现在开始移植bluez的库文件和工具集。使用的版本是 bluez-lib-3.36和bluez-utils-3.36。arm-linux-gcc的版本为3.3.2 内核版本为kernel-2.6.13 编译内核和根文件系统要使用相同版本的交叉编译工具,否则编译出来的命令不能执行,出现段错误。

   configure时的一点建议,configure脚本指定make install的安装目录,--prefix= 可以配置,个人感觉还是不使用这个选项。这样一般会安装到/usr下,(具体看源代码的INSTALL文件),所以编译完成后一定不能make isntall!否则会覆盖宿主系统的软件。这样做的好处是使你的目标系统目录结构很清晰,比如/usr/bin下存放的都是用户的可执行文件。/etc下都是各个软件的配置文件目录。软件的临时文件都存放在/tmp下,log信息/var下。因此我只make编译出可执行文件或库文件,然后手工拷贝到目标板中响应目录下。但这样做的前提是你要知道需要拷贝那些文件以及他们的位置。一个是通过INSTALL文件。另一个笨方法是编译两次,第一次指定--prefix=,编译并安装,查看都需要那些文件以及他们的位置,第二次不使用--prefix=只编译不安装,并参考第一次手动拷贝。

   两次编译还有一个好处是当这个源代码包被其他的源码包所依赖时,可以使用生成的.pc文件替换宿主系统的.pc文件,为其他包的编译带来便利。具体原理和用方法请参考pkg-config的用法。

   当然也可以使用configure的其他选项来自定义你的目录结构,--bindir & --exec-prefix=PREFIX等。具体的参考--help帮助。

现在将编译中遇到的错误贴出来:

1. 编译bluez-libs-3.36

[mystic@moolenaar]$ ./configure --host=arm-linux  CC=arm-linux-gcc 

make编译通过。把make后生成的bluez.pc文件拷贝到/usr/lib/pkgconfig目录但要做好pc版本的bluez.pc的备份。下以便交叉编译完bluez后恢复。这个bluez.pc要使用

copy bluez.pc to usr/lib/pkgconfig

 

2. 编译bluez-utils-3.36,缺少D-Bus

[mystic@moolenaar]$ ./configure --host=arm-linux  

checking pkg-config is at least version 0.9.0... yes

checking for BLUEZ... yes

checking for GLIB... no

checking for GMODULE... no

checking for dlopen in -ldl... yes

checking for DBUS... no

configure: error: D-Bus library is required

 

bluez-utils需要d-bus包的支持,下载d-bus的源代码编译安装。bluez-utils需要的其他一些源码包将在最后贴出。(包括使用的版本号)

 

3. 编译D-Bus,can not run test program while cross compiling

[mystic@moolenaar]$ ./configure --host=arm-linux --prefix=/bluez/dbus  CC=arm-linux-gcc

checking for getpeereid... no

checking abstract socket namespace... configure: error: cannot run test program while cross compiling

See `config.log' for more details.

执行./configure时要在宿主系统中运行一些测试程序,因为是交叉编译所以这个测试是一定通不过的。不过没问题,我们可以在configure时指定cache-file文件来屏障掉测试程序,在下面编译glib包时会遇到同样的问题。

 

处理方法:

在源码包根目录下执行

[mystic@moolenaar]$ echo ac_cv_have_abstract_sockets=yes > arm-linux.cache

[mystic@moolenaar]$ ./configure --host=arm-linux --prefix=/bluez/dbus  CC=arm-linux-gcc --cache-file=arm-linux.cache

 

./configure通过后,执行make,出现如下错误:

make[2]: *** [config-loader-libxml.o] error 1

make[2]: Leaving directory `/3.3.2/dbus-1.0.2/bus'

make[1]: *** [all-recursive] error 1

make[1]: Leaving directory `/3.3.2/dbus-1.0.2'

make: *** [all] error 2

缺少xml库,下载编译安装后,copy  libxml-2.0.pc /usr/lib/pkgconfig 就可以了。

 

4. 编译dbus,cannot find -lX11

[mystic@moolenaar]$ make

arm-linux/bin/ld: cannot find -lX11

collect2: ld returned 1 exit status

make[2]: *** [dbus-launch] error 1

make[2]: Leaving directory `/3.3.2/dbus-1.0.2/tools'

make[1]: *** [all-recursive] error 1

make[1]: Leaving directory `/3.3.2/dbus-1.0.2'

make: *** [all] error 2

在开发板上不需要X Server. configure直接屏蔽掉。

 

[mystic@moolenaar]$ ./configure --host=arm-linux --prefix=/bluez/dbus  CC=arm-linux-gcc --cache-file=arm-linux.cache --without-x

 
5. 编译bluez-utils, 缺少宏定义

bridge.c:82: error: `SIOCBRADDBR' undeclared (first use in this function)

bridge.c:82: error: (Each undeclared identifier is reported only once

bridge.c:82: error: for each function it appears in.)

bridge.c: In function `bridge_remove':

bridge.c:100: error: `SIOCBRDELBR' undeclared (first use in this function)

bridge.c: In function `bridge_add_interface':

bridge.c:126: error: `SIOCBRADDIF' undeclared (first use in this function)

make[2]: *** [bridge.lo] error 1

make[2]: Leaving directory `/3.3.2/bluez-utils-3.36/network'

make[1]: *** [all-recursive] error 1

make[1]: Leaving directory `/3.3.2/bluez-utils-3.36'

make: *** [all] error 2

 

bluez-utils-3.36/network/bridge.h中添加如下宏定义:

#define SIOCBRADDBR     0x89a0          /* create new bridge device     */

#define SIOCBRDELBR     0x89a1          /* remove bridge device         */

#define SIOCBRADDIF     0x89a2          /* add interface to bridge      */

#define SIOCBRDELIF     0x89a3          /* remove interface from bridge */

 

6. 编译bluez-utils

[mystic@moolenaar]$ make

storage.c  -fPIC -DPIC -o .libs/storage.o

storage.c: In function `encrypt_link':

storage.c:286: error: `ENOKEY' undeclared (first use in this function)

storage.c:286: error: (Each undeclared identifier is reported only once

storage.c:286: error: for each function it appears in.)

make[2]: *** [storage.lo] error 1

make[2]: Leaving directory `/3.3.2/bluez-utils-3.36/input'

make[1]: *** [all-recursive] error 1

make[1]: Leaving directory `/3.3.2/bluez-utils-3.36'

make: *** [all] error 2

 

在bluez-utils-3.36/input/storage.c加入宏定义

#define ENOKEY EACCES

 

还会遇到缺少audio模块的错误,我的蓝牙中没有使用audio,所以在./configure时也直接--disable-audio。

 

bluez-utils-3.36依赖的其他源码包:

[glib必须使用2.14以后版本。编译utils包时,g_timeout_add_seconds函数在此版本以后定义]

 

dbus-1.0.2

glib-2.14.4

libxml2-2.6.11

libsndfile-1.0.17

libusb-0.1.12

 

文件: dbus-1.0.2.tar.gz
大小: 1367KB
下载: 下载

文件: libxml2-2.6.11.tar.gz
大小: 3607KB
下载: 下载

文件: glib-2.14.4.tar.gz
大小: 4426KB
下载: 下载
文件: libsndfile-1.0.17.tar.gz
大小: 800KB
下载: 下载

文件: libusb-0.1.12.tar.gz
大小: 380KB
下载: 下载

 

 

 
阅读(17992) | 评论(12) | 转发(1) |
0

上一篇:移植squid3

下一篇:开发板的自动进入shell

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

chinaunix网友2011-04-15 08:06:04

将安装好的lib/pkconfig/下面的文件拷贝到/usr/lib/pkconfig下,问题应该就解决了。

hylhyjwx2010-04-28 15:28:33

库文件是安装了的,就是按照上面到步骤把你附件的东西安装上去的。去到lib目录下都有dbus那些文件,但就是找不到,不知道怎么回事了

_mystic2010-04-28 11:33:59

你安装了d-bus的库文件没有?d-bus库是用来为其他软件连接的。 不是d-bus工具。

hylhyjwx2010-04-26 15:19:59

解决方法发到我邮箱把。hylhyjwx@163.com

hylhyjwx2010-04-26 15:19:12

我跟楼上一样,我已经装好了dbus,但是就是说找不到/。///