Using bluetooth with gcc



  • Hi everyone!
    For a project, I have to develop a simple C/C++ programm, which uses bluetooth, on a Onion Omega2 where I installed gcc compiler. To use bluetooth, I tried to install the bluetooth library "BlueZ" (downloaded from www.bluez.org) following the guide included in the package but with no positive result. In fact, the "configure" step returns several errors of missing library/packages (eg. librt, glib, udev, d-bus, d-bus, ...) which however are actually present in the device.
    Was anyone else in the same situation? In this case, did you resolve the problem? If yes, how did you fix it? Or did you find an alternative way?

    Thanks in advance for your answers.



  • Even though you may have glib, udev, d-bus on the omega, for sure you do not have headers (*.h) for these on the omega. On the bigger linux devices, you always have extra packages available for these headers, for example build-essentials or libbluetooth-dev on the debian. You need to cross compile using LEDE or install headers locally on the Omega.



  • Thank you Arek Z for answering. I've followed the guide for setting up the cross compilation toolochain on kubuntu (using virtual machine) and I tried to use it. I managed to cross-compile and then run on the Onion2 both simple programms (e.g. "hello world") and the "c-cross-compile-example" which required to install/import gpio library.
    So I follow the same procedure for bluez-libs but, when I run the make command to compile again the toolchain, this error occours (to see it I run "make V=s"):

    0_1521370716191_cross_blue_err.jpg

    Do you know how I can resolve it?



  • @Tommaso-Vescovo not sure if you are aware of the un-comment of repos to gain additional files but i did a opkg list search on "blue" and got this back. thought i would post it in case you had not seen these files.

    root@Omega-325F:~# opkg list | grep blue
    bluelog - 1.1.2-2 - Bluelog is a simple Bluetooth scanner designed to tell you how many discoverable devices there are in an area as quickly as possible. It is intended to be used as
    a site survey tool, identifying the number of possible Bluetooth targets there are in the surrounding environment.
    bluelog-live - 1.1.2-2 - Bluelog is a simple Bluetooth scanner designed to tell you how many discoverable devices there are in an area as quickly as possible. It is intended to be use
    d as a site survey tool, identifying the number of possible Bluetooth targets there are in the surrounding environment. This package contains the files for "Bluelog Live", an optional
    mode of Bluelog which creates a real-time webpage of discovered Bluetooth devices.
    bluez-daemon - 5.47-1 - Bluetooth daemon
    bluez-examples - 5.47-1 - contains many examples apps for bluetooth, requiring python
    bluez-libs - 5.47-1 - Bluetooth library
    bluez-libs - 5.30-1 - Onion-Customized Bluetooth library
    bluez-utils - 5.47-1 - Bluetooth utilities
    bluez-utils - 5.30-1 - Onion-Customized Bluetooth utilities
    gnunet-transport-bluetooth - 0.10.2-git-20180205-b673e9c3ed4a211b974bc602b893a427533566d7-1 - GNUnet bluetooth transport
    ibt-firmware - 2017-09-06-a61ac5cf-1 - Intel bluetooth firmware
    jamvm - 2.0.0-1 - JamVM is a new Java Virtual Machine which conforms to the JVM specification version (blue book). In comparison to most other VM's (free and commercial) it is extreme
    ly small.However, unlike other small VMs (e.g. KVM) it is designed to support the full specification, and includes support for object finalisation, Soft/Weak/Phantom References, the J
    ava Native Interface (JNI) and the



  • @Douglas-Kryder, I'm aware of this but that's not the problem. The error occurs before the cross-compilation, namely when I start, on the computer, the configuration to create the toolchain for the cross-compilation.



  • In this days I tried cross-compile both with VM Ubuntu and with Docker Toolbox but I wasn't able to include bluetooth library. Does anyone know how to do it?

    For the test, I used this example:
    http://people.csail.mit.edu/albert/bluez-intro/c404.html

    Edit: I found in Docker the bluez-lib and they run well but work in that conteiner is laborious (I have to use transfer.sh website to transfer files). Where can I found the Makefile to compile bluez-lib in the LEDE Configurator in order to use it in Ubuntu too?



Looks like your connection to Community was lost, please wait while we try to reconnect.