C++ 在RaspberryPi上使用gcc编译蓝牙问题

C++ 在RaspberryPi上使用gcc编译蓝牙问题,c++,c,gcc,bluetooth,raspbian,C++,C,Gcc,Bluetooth,Raspbian,我用的是Raspbian(Debian哮喘病)。我已经安装了 $ sudo apt-get install bluez bluez-tools bluez-dbg bluez-hcidump bluez-tools python-bluez libbluetooth-dev libbluetooth3 libbluetooth3-dbg 但当试图编译以下行时,它表示不知道库: $ gcc scanbd.c -o scanbd /tmp/ccl5BrFc.o: In function `main

我用的是Raspbian(Debian哮喘病)。我已经安装了

$ sudo apt-get install bluez bluez-tools bluez-dbg bluez-hcidump bluez-tools python-bluez libbluetooth-dev libbluetooth3 libbluetooth3-dbg
但当试图编译以下行时,它表示不知道库:

$ gcc scanbd.c -o scanbd
/tmp/ccl5BrFc.o: In function `main':
scanbd.c:(.text+0x84): undefined reference to `hci_get_route'
scanbd.c:(.text+0x90): undefined reference to `hci_open_dev'
scanbd.c:(.text+0x11c): undefined reference to `hci_inquiry'
scanbd.c:(.text+0x170): undefined reference to `ba2str'
scanbd.c:(.text+0x1c8): undefined reference to `hci_read_remote_name'
collect2: ld returned 1 exit status
以下是我在.c文件中的include语句:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#包括
#包括
#包括
#包括
#包括
#包括
#包括
有人知道我做错了什么吗? 谢谢

更新:事实证明我做了所有正确的事情,但我必须关闭/拔下RPi,然后重新启动,以便一切正常工作。。。在那之后,那颗蓝牙就在小路上了。
谢谢大家

希望下面的链接能帮助你们

编译时,请将参数-lbluetooth放在scannbd.c之后,如下所示:

例:
gcc scanbd.c-lbluetooth-o scanbd

安装蓝牙库是不够的,您还需要将它们链接到您的程序。将
-lbluetooth
添加到编译器命令中,未定义的引用错误将消失。很抱歉造成混淆,我使用行“#gcc-o scanbd scanbd.c-lbluetooth”进行编译。它说,没有这样的文件或目录“蓝牙”。蓝牙库文件的文件扩展名是什么?也许我可以搜索一下,看看是否安装了。或者它不在这条路上?尽管我添加了/usr/include和/usr/library路径。当我从编译器命令中删除-lbluetooth库时,我得到了hci_*错误。正如我提到的,当我重新添加-lbluetooth时,它表示它不知道它。当您将
-lbluetooth
附加到gcc命令时,您可以编辑您的问题并添加输出吗<代码>gcc-o scanbd scanbd.c-lbluetooth(这是DASH ELL BEE ELL EWE EEE…等等)