我是一个新的stackoverflow用户!我正在写作,因为我在KUbuntu 12.04上使用C编程蓝牙时遇到了一些问题.
我正试图通过我在这个pdf(启动连接)中找到的程序将设备(LEGO Mindstorm Brick)连接到我的笔记本:
NXT_Bluetooth_Handout
我安装了以下软件包:
– bluez-hcidump,通讯调试工具
– bluez,Linux蓝牙堆栈和相关工具
– libBluetooth3,BlueZ库
– libBluetooth-dev,用于链接到BlueZ库的开发文件
// Socket, used for Bluetooth socket
#include
#include
// Bluetooth headers
#include
#include
主要是我遇到两个问题:
1)如果我只是尝试编译我得到的程序:
$gcc -lm -lbluetooth nxt_bt_connect.c -o nxt_bt_connect
/tmp/ccSLdkpn.o: In function `init_bluetooth':
nxt_bt_connect.c:(.text+0x60): undefined reference to `str2ba'
collect2: ld returned 1 exit status
其中str2ba是一个BlueZ函数,它应该可以工作… ba2str是这个库提供的另一个函数,它可以正常工作.
2)如果我修改代码以使用ba2str而不是str2ba函数我得到一个与套接字相关的错误:
$gcc -lm -lb