56

I want to build a c file based on BlueZ but seems no bluetooth.h file in my system.

fatal error: bluetooth/bluetooth.h: No such file or directory

I am sure the bluetooth dongle is running correctly and I have built Bluez successfully.

Update

For my case, I find the bluetooth.h in /user/include/bluetooth folder

Youssif Saeed
  • 11,789
  • 4
  • 44
  • 72
Yiding
  • 2,914
  • 3
  • 21
  • 16
  • So you know where bluetooth.h is, but you're c compiler doesn't. You need to include /user/include/bluetooth in your compilers directory search – user3288829 May 02 '14 at 21:24
  • This isn't necessarily the issue you face, but on some linux distributions, there's the binary version of packages which provide runtime support, and then a separate "-dev" package which contains what you need to link your own programs against provided libraries. Perhaps you don't have the -dev package for bluez installed. (Yes, I know you found a header - but there may be more to the puzzle) – Chris Stratton May 02 '14 at 21:51
  • @ChrisStratton Yes. I think you are right. Will try to add the dev library. – Yiding May 04 '14 at 18:10
  • 1
    @user3288829 will that be too tedious? I mean if I change the path later I have to change every file's include path. – Yiding May 04 '14 at 18:11
  • 4
    Hopefully `/user/include/bluetooth` is a typo in your post. If not, then your probablem is that you accidentally ended up with something installed under /user what belongs under /usr where it should be picked up as part of standard include paths. – Chris Stratton May 04 '14 at 18:28

3 Answers3

115

You need to install libbluetooth-dev package for compiling your code

sudo apt-get install libbluetooth-dev

That should install the bluetooth header files.

Rahul R Dhobi
  • 5,668
  • 1
  • 29
  • 38
  • Is it possible to solve this without installing this file? I only need to compile , i am not allowed to install it. – Black Aug 06 '15 at 13:16
  • 4
    Yes download and extract .deb file and provide include directory to CLFAGS=-I/path/to/libbluetooth-dev/headerfiles while configuring BlueZ – Rahul R Dhobi Aug 07 '15 at 04:20
  • I am using bluetooth APIs in Qt which in turn uses bluez on linux, do you know what I need to do to link bluez to Qt? thanks. I imagine I still have to execute install with the line you posted. – zar Oct 13 '15 at 19:07
  • @zadane: I don't know actually but you should try Qt Bluetooth http://doc.qt.io/qt-5/qtbluetooth-index.html – Rahul R Dhobi Oct 14 '15 at 04:50
  • The solution provided didn't work for me. The reason is that the make file of the official source distribution is searching in the directory `/usr/include`, meanwhile the headers are in `/usr/include/bluetooth`. I had to copy all the headers from the bluetooth directory to `/usr/include`. I hope this help! – noun Jul 30 '18 at 16:51
  • 1
    @noun you've messed everything up by doing that. The correct include is `#include ` – OrangeDog Apr 27 '21 at 09:37
  • THIS IS ANCIENT Installing sudo apt-get install libbluetooth-dev PACKAGE is normal . standard Linux install.. LOCATING the actual library to tell compiler to link with has not been answered. –  Mar 20 '22 at 19:04
10

For Fedora, you can use:

sudo dnf install bluez-libs-devel
4b0
  • 21,981
  • 30
  • 95
  • 142
Abishek Balu
  • 101
  • 1
  • 2
1

On CentOS 7:

sudo yum install bluez-libs-devel
SBF
  • 1,252
  • 3
  • 12
  • 21