Based on bluez Program Notes during compilation
First, do not include the content defined in the bluez header file. Bluetooth/Bluetooth. H should be added first. For example: // ================================================================/bluetooth Header file # include <Bluetooth/Bluetooth. h> // btproto_hci # include <Bluetooth/HCI. h> // struct hci_dev_info # include <Bluetooth/hci_lib.h> // hci_devid () # include <Bluetooth/L2CAP. h> // L2CAP # include <Bluetooth/hidp. h> // hidp Second: in Linux, Bluetooth is implemented through socket. Sa_family_t will be used. Bluetooth/HCI. h. Therefore, you must include the socket header file before the include Bluetooth header file. # include <sys/types. h> # include <sys/socket. h> otherwise, a problem similar to the following occurs: Bluetooth/HCI. h: 1091: Error: Expected specifier-qualifier-list before 'sa _ family_t 'is transferred from: http://elsila.bokee.com/6978899.html and above can also be used in socketcan