linux下bluez的移植

上传人:真** 文档编号:85415040 上传时间:2022-05-05 格式:DOC 页数:7 大小:29KB
收藏 版权申诉 举报 下载
linux下bluez的移植_第1页
第1页 / 共7页
linux下bluez的移植_第2页
第2页 / 共7页
linux下bluez的移植_第3页
第3页 / 共7页
资源描述:

《linux下bluez的移植》由会员分享,可在线阅读,更多相关《linux下bluez的移植(7页珍藏版)》请在装配图网上搜索。

1、linux下bluez的移植 bluez的移植可以用两个字概括:麻烦!原因是它不是单纯的bluez的编译,它还需要其他很多的库的支持,下面先列举一下这些库的麻烦依赖关系吧: bluez-libs-3.36(不需要其他库)bluez-utils-3.36:glib-2.16.5dbus-1.0.2:libxml2-2.7.4libsndfile-1.0.17libusb-0.1.12 前面两个必须的,后两个看你的配置,bluez4也一样;下面开始编译: Bluez移植到arm s3c2410上 搞了好几天的蓝牙协议栈(bluez)的移植,现在终于有点小成就了,写下来和大家分享。以下介绍Bluez

2、移植的基本步骤。一,linux内核的配置Linux2.6版本之后的内核一般都有蓝牙模块的配置,所以你不用再打补丁了。由于我也是处于摸索阶段,所以我暂时用的是开发板上自带的内核。#tarzxvflinux.2.6.*解压缩内核,进入内核目录。在名令行输入#makedisclean/makeclean/makermproper,选择这三个中的任意一个对内核进行清理,关于这三个命令的区别你可以google一下,然后自己去区分。#makemenuconfig/makeconfig/makeoldconfig/makexconfig输入如这三个命令中的任何一个,对内核进配置,这几条命令的区别,请你自己g

3、oogle。推荐使用makemenuconfig。进入内核配置界面之后,根据你的自己的需要进行选择。关于内核的配置请单独查看内核配置方面的文档。#makezImageARCH=arm CROSS_COMPILE=arm-linux-到此内核镜像就已经做好了。二,编译bluez协议栈。移植过蓝牙协议栈的人,肯定会觉得,Bluez协议栈的编译是最麻烦的一件事情。其实,如果你能理清楚bluez-utils所依赖的一些库,你就能很快的cross-compile交叉编译出一套能在开发板上跑起来的程序。关键是如何去理清楚协议,我总结出来的方法是,倒着推,你不知道bluez-utils依赖那些库,那就先直接

4、编译bluez-utils,根据编译显示的错误,分析错误,找出来它所依赖的库,这样一步一步的分析下去,你就可以把蓝牙协议栈交叉编译出来。如果你不会分析错误或则不想去分析,可以,那你就直接把错误粘贴到网上,让搜索引擎给你找。由于时间的仓促,这里我只列出我已经总结出来的Bluez所需要的几个库,以及几个库编译的先后顺序。注:/opt/libs和/opt/utils是我自己编译时用的路径,你可以随便的选取。1,编译安装bluez-lib-3.36.tar.gz这个库不需要什么依赖,直接解压,配置,编译然后安装即可。#tarzxvfbluez-lib-3.36.tar.gz#./configure-p

5、rofix=/opt/libs-host=arm-linux-target=arm-linuxCC=arm-linux-gcc#make#makeinstall2,编译安装这个库是后面的dbus依赖的,你也可以用expat来代替libxml2,官方网站上说dbus必须依赖于他们中的一个。#tarzxvf libxml2-2.7.4.tar.gz#./configure-profix=/opt/libs-host=arm-linux-target=arm-linuxCC=arm-linux-gcc#make#makeinstall3,编译安装dbus-1.0.2.tar.gz#tarzxvfdb

6、us-1.2.16.tar.gz#echoac_cv_have_abstract_sockets=yesarm-linux.cache#./configure-profix=/opt/libs-host=arm-linux-target=arm-linuxCC=arm-linux-gcc-I/opt/libs/include-L/opt/libs/lib-cache-file=arm-linux.cache-with-x=no#make#makeinstall4,编译安装glib-2.16.5#tar-zxjf glib-2.16.5.tar.bz2#echoac_cv_type_long_l

7、ong=yesarm-linux.cache#echoglib_cv_stack_grows=noarm-linux.cache#echoglib_cv_uscore=noarm-linux.cache#echoc_cv_func_posix_getpwuid_r=yesarm-linux.cache#echoac_cv_func_posix_getgrgid_r=yes注意:和的区别#./configure-profix=/opt/libs-host=arm-linux-target=arm-linuxCC=arm-linux-gcc-I/opt/libs/include-L/opt/lib

8、s/lib-cache-file=arm-linux.cache#make#makeinstall5,编译安装libusb-0.1.12.tar.gz这个库不需要什么依赖,直接解压,配置,编译然后安装即可。#tarzxvflibusb-0.1.12.tar.gz#./configure-profix=/opt/libs-host=arm-linux-target=arm-linuxCC=arm-linux-gcc-I/opt/libs/include-L/opt/libs/lib#make#makeinstall6,编译安装bluez-utils-3.36.tar.gz#tarzxvfblue

9、z-utils-3.36.tar.gz#./configure-profix=/opt/libs-host=arm-linux-target=arm-linuxCC=arm-linux-gcc-I/opt/libs/include-L/opt/libs/lib-disable-audio#make#makeinstall这样Bluez协议栈就编译好了。三,烧写到开发板上 实际上放到板上的只需要l2cap.o libbluetooth.so.2.11.2 start.sh libbluetooth.so bnep.o libbluetooth.so.2 hci_usb.o rfcomm.osta

10、rt.sh是启动模块的支持,也可以insmod进去,其他的是程序要用到的库。可能遇到的错误及解决方法:a、编译程序的时候wenwen-desktop:$ arm-linux-gcc -I/home/wen/bluez/bluez-libs-3.36_install/include -L/home/wen/bluez/bluez-4.69/lib/.libs client.c -o client_arm/tmp/ccGbPHFl.o(.text+0x38): In function main: undefined reference to hci_get_route/tmp/ccGbPHFl.o

11、(.text+0x48): In function main: undefined reference to hci_open_dev/tmp/ccGbPHFl.o(.text+0xd4): In function main: undefined reference to str2bacollect2: ld returned 1 exit statuswenwen-desktop:$ arm-linux-gcc -I/home/wen/bluez/bluez-libs-3.36_install/include -L/home/wen/bluez/bluez-4.69/lib/.libs -l

12、bluetooth client.c -o client_armwenwen-desktop:$-lbluetooth 就是代表-llibbluetooth.so -L -lbluetooth就是找此目录下的libbluetooth.so或者libbluetooth.a去链接b、libgmodule.so :invalid reconizelibgmodule.so在glib里面,再在配置文件中改为CC=armlinuxgcc Lglib_lib_dirc、storage.c:286: error: ENOKEY undeclared (first use in this function)在

13、 bluez-utils-3.36/input/storage.c 中添加宏定义:#define ENOKEY 161 d、_libc_csu_init undefined reference to _init_array_end配置文件里面的编译器加-shared为:CC=armlinuxgcc -shared 。e、cc1: error: unrecognized command line option -fvisibility=hidden说是编译器版本太低的缘故。在高版本里面才支持-Wno-pointer-sign、-fvisibility=hidden。后来使用PC上的编译器(gcc

14、版本4.4.1,而arm-linux-gcc是3.4.4)试了一下,就没出现这个错误,由此可推断确实是编译器版本问 题。既然低版本没有这个指令,我就删掉libusb-compat-0.1.3/libusb/Makefile里面的-Wno-pointer- sign和-fvisibility=hidden,之后OK(如果其他Makefile也有,也要删)。编完之后也要将库和头文件复制到工具链里 面去。f、configure: error: Netlink library is required解决方法: apt-get install libnl-dev and libnl-doch、 解决安装

15、glib的编译错误stack pointer 问题:echo ac_cv_type_long_long=yesarm-linux.cacheecho glib_cv_stack_grows=noarm-linux.cacheecho glib_cv_uscore=noarm-linux.cacheecho ac_cv_func_posix_getpwuid_r=yesarm-linux.cachei、configure: error: Could not find a glib-genmarshal in your PATH网上:解压glib2-devel-2.4.7-1.tar.gz, 将文

16、件复制到/usr/local下面实际:$ sudo apt-get install libglib2.0-dev原来下载个这东西就行了j、checking for growing stack pointer. configure: error: cannot run test program while cross compiling#echo ac_cv_type_long_long=yesarm-linux.cache#echo glib_cv_stack_grows=noarm-linux.cache#echo glib_cv_uscore=noarm-linux.cache#echo

17、c_cv_func_posix_getpwuid_r=yesarm-linux.cachek、checking for posix getpwuid_r. configure: error: in /home/yan/glib-2.22.4:configure: error: cannot run test program while cross compilingSee config.log for more details.解决方法:ppcst# echo ac_cv_func_posix_getwuid_r=yesl、源代码安装glib-2.22.5rootzhupan-desktop:

18、/home/zhupan/glib-2.22.5# ./configureconfigure: error:* You must have either have gettext support in your C library, or use the* GNU gettext library. (http:/www.gnu.org/software/gettext/gettext.html解决:i. 尝试 apt-get install gettex,错误,提示:E: 无法找到软件gettextii. 下载gettext-0.16.1安装m、configure: error: Netlin

19、k library is requiredconfigure: error: dbus library is required1、wenwen-desktop:/bluez/bluez-4.69$ export DBUS_CFLAGS=/home/wen/bluez/libxml/include /libxml2/libxmlwenwen-desktop:/bluez/bluez-4.69$ export DBUS_LIBS=/home/wen/bluez/libxml/lib2、把编译出来的两个lib的pkconfig里面的.pc放到usr/lib/pkgconfig/里面,或者设置在PKG

20、_CONFIG_PATH里面n、. 编译D-Bus,can not run test program while cross compilingmysticmoolenaar$ ./configure -host=arm-linux -prefix=/bluez/dbus CC=arm-linux-gccchecking for getpeereid. nochecking abstract socket namespace. configure: error: cannot run test program while cross compilingSee config.log for mo

21、re details.执行./configure时要在宿主系统中运行一些测试程序,因为是交叉编译所以这个测试是一定通不过的。不过没问题,我们可以在configure时指定cache-file文件来屏障掉测试程序,在下面编译glib包时会遇到同样的问题。处理方法:在源码包根目录下执行mysticmoolenaar$ echo ac_cv_have_abstract_sockets=yes arm-linux.cachemysticmoolenaar$ ./configure -host=arm-linux -prefix=/bluez/dbus CC=arm-linux-gcc -cache-f

22、ile=arm-linux.cacheo./configure出现checking for C compiler default output file name. configure: error: C compile cannot execulable查看:config.log文件,发现是环境变量(LIBS LDFLAGS)设置错误,和libp、configure: error: libxml library is required缺少xml库,下载编译安装后,copy libxml-2.0.pc /usr/lib/pkgconfig 就可以了。q、/bin/rm: cannot remo

23、ve libtoolT: No such file or directoryDone configuringlibxml的配置出现以上问题;解决:可以直接编译make,不影响r、/tmp/ccs2uTxL.o(.text+0x38): In function main: undefined reference to hci_get_route/tmp/ccs2uTxL.o(.text+0x48): In function main: undefined reference to hci_open_dev/tmp/ccs2uTxL.o(.text+0xd4): In function main:

24、 undefined reference to str2bacollect2: ld returned 1 exit status解决方法:-lbluetooths、client.c:3:22: bluetooth.h: No such file or directoryclient.c:4:16: hci.h: No such file or directoryclient.c:5:20: hci_lib.h: No such file or directoryclient.c:6:19: rfcomm.h: No such file or directory解决方法:I头文件目录t、转er

25、ror: cannot run test program while cross compili在交叉编译的时候总是使用configure -host=arm-linux 嘿嘿但是在CONFIGURE中有很多的测试程序是不可以在HOST上运行的就会出现: error: cannot run test program while cross compiling注意到abstract socket namespace在configure中查找abstract socket可以看到类似这样的结构echo $as_me:$LINENO: checking abstract socket namespa

26、ce &5echo $ECHO_N checking abstract socket namespace. $ECHO_C &6if test $ac_cv_have_abstract_sockets+set = set; thenecho $ECHO_N (cached) $ECHO_C &6其中ac_cv_have_abstract_sockets是我们要查找的变量使用echo ac_cv_have_abstract_sockets=yesarm-linux.cache然后./configure -host=arm-linux -cache-file=arm-linux.cacheOK这样就搞定了u、问题:arm_linux -randlgcc cannoe found解决办法:到root权限下make 并检查arm-linux-gcc 有没有加到PATH中v、configure: error: GLib library version 2.14 or later is required1 设置环境变量GLIB与LIBS, ./configure -help里面查看;2 把编出来的库lib/pkconfig/*.pc放到/usr/lib/pkgconfig

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!