Ubuntu Bluetooth环境搭建
1. 准备
准备:bluez-libs-3.36.tar.gz (blurtooth所需要的库及头文件)
2. 安装
tar –xvf bluez-libs-3.36.tar.gz cd bluez-libs-3.36 ./configure make sudo make install |
3. 修改
一般情况下,到此就算完成了,但实际情况是到此为止,所编写的程序编译不过,会报错。
a.错误1:
类似: /usr/local/include/bluetooth/hci_lib.h:124:23: error: unknown type name ‘uint32_t’ char *hci_dflagstostr(uint32_t flags); |
这是uint32_t等类型找不到,应该包含头文件<stdint.h>,将此头文件添加到bluetooth头文件/usr/local/include/bluetooth/hci.h中:
b.错误2:
类似: /usr/local/include/bluetooth/hci.h:1559:2: error: unknown type name ‘bdaddr_t’ bdaddr_t bdaddr; |
这是在hci.h等文件中用到了bdaddr_t,但是又找不到此结构,bdaddr_t是在bluetooth.h中定义的,因此在/usr/local/include/bluetooth/hci.h中添加头文件bluetooth.h即可:
4. 编译说明
在编译时不用添加库名,直接编译:
linux@linux-vm:~/ex$ gcc -o bluetooth bluetooth_test.c linux@linux-vm:~/ex$ ./bluetooth |