2

Following this howto I'm cross-compiling a bluetooth application for Raspberry Pi (ARM). When I try to link with libbluetooth I get the error below. Even the simplest helloworld application (without bluetooth code) won't link.

arm-linux-gnueabihf-g++ -c hello.cpp -o hello.o
arm-linux-gnueabihf-g++ hello.o -o hello -lbluetooth -L/home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf
/home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.so: undefined reference to `__fdelt_chk@GLIBC_2.15'


sbf@sbf-VirtualBox ~/raspberrypi/projects/test $ ls -al /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth*
-rw-r--r-- 1 sbf sbf 132886 May 27  2016 /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.a
lrwxrwxrwx 1 sbf sbf     23 Nov 24 21:20 /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.so -> libbluetooth.so.3.17.11
lrwxrwxrwx 1 sbf sbf     23 Nov 24 21:20 /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.so.3 -> libbluetooth.so.3.17.11
-rw-r--r-- 1 sbf sbf 103376 May 27  2016 /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.so.3.17.11

Edit (added): GLIBC Version 2.19

pi@raspberrypi:~ $ ldd --version
ldd (Debian GLIBC 2.19-18+deb8u6) 2.19

What's going wrong?

Community
  • 1
  • 1
SBF
  • 1,252
  • 3
  • 12
  • 21
  • What's the version of glibc? – Starl1ght Dec 01 '16 at 09:24
  • 1
    @Starl1ght GLIBC 2.19 (on RPi from where I copied `/usr/*` and `/lib/*`) – SBF Dec 01 '16 at 09:40
  • But what version of glibc is the cross-toolchain using (since -L won't override its built-in sysroot)? I bet that's where the problem lies. – Notlikethat Dec 01 '16 at 09:59
  • @Notlikethat How can I find the version of glibc? `arm-linux-gnueabihf-ldd --version` shows me `ldd (crosstool-NG) linaro-1.13.1-4.8-2014.01` – SBF Dec 01 '16 at 10:30

1 Answers1

5

I was experiencing the same issue yesterday trying to link libbluetooth using raspberry pi tools.

To solve this I downloaded a newer version of Linaro dev tools (6.1.1) than what is supplied by the raspberry pi tools repository.

Here is the link to the latest linaro toolchain release

Download "gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabihf.tar.xz" and put that folder in your raspberrypi/tools/arm-bcm2708/ directory along with the other toolchains.

Then set compiler/linker paths to point to the new directory.

(I am using cmake)

SET(CMAKE_C_COMPILER $ENV{HOME}/raspberrypi/tools/arm-bcm2708/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc) SET(CMAKE_CXX_COMPILER $ENV{HOME}/raspberrypi/tools/arm-bcm2708/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++)

(edit) I had trouble running my executable with this version of the toolchain compiled since jessie doesn't support gcc versions 5 or 6. Instead try using this release https://releases.linaro.org/components/toolchain/binaries/4.9-2016.02/arm-linux-gnueabihf/

  • 1
    Or just use `--sysroot=` to use the real target libraries instead of relying on the ones packaged with the cross-toolchain. – Notlikethat Dec 02 '16 at 12:33