glibc version mismatch with Ubuntu 22.04 cross-compile to BBG Bullseye 2022-05-01

I’ve taught a university Embedded Systems course targeting the BeagleBone Green for a number of years. I’m updating the host OS from Ubuntu 20.04 to 22.04 (Jellyfish).

However, this cause a version problem with GLIBC when cross-compiling:
./helloworld: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.34’ not found (required by ./helloworld)

Any suggestions on how I can best force the host to cross-compile using a version of GLIBC which is compatible with the BBG?

Thank you for any ideas!

Details
The binaries are cross-compiled from the Ubuntu host using arm-linux-gnueabihf-gcc:

	(host)$ sudo apt-get install gcc-arm-linux-gnueabihf
	(host)$ arm-linux-gnueabihf-gcc helloworld.c -o helloworld

Under Ubuntu 22.04 I have also tried with packages gcc-9-arm-linux-gnueabihf, gcc-10-arm-linux-gnueabihf, and gcc-11-arm-linux-gnueabihf.

The BBG is running Debian Bullseye Minimal Image (2022-05-01) Monthly Snapshot, which seems to have GLIBC version 2.31:

(bbg)$ strings /lib/arm-linux-gnueabihf/libc.so.6 | grep GLIBC
	GLIBC_2.4
	<...snip...>
	GLIBC_2.30
	GLIBC_PRIVATE
	GNU C Library (Debian GLIBC 2.31-13+deb11u3) stable release version 2.31.

Ubuntu 20.04 seems to be building against GLIBC version 2.31:

(20.04)$ strings /usr/arm-linux-gnueabihf/lib/libc.so.6 | grep GLIB
	GLIBC_2.4
	<...snip...>
	GLIBC_2.30
	GLIBC_PRIVATE
	GNU C Library (Ubuntu GLIBC 2.31-0ubuntu9.2) stable release version 2.31.

Ubuntu 22.04 seems to be building against GLIBC version 2.35:

(22.04)$ strings /usr/arm-linux-gnueabihf/lib/libc.so.6 | grep GLIB
	GLIBC_2.4
	<...snip...>
	GLIBC_2.35
	GLIBC_PRIVATE
	GNU C Library (Ubuntu GLIBC 2.35-0ubuntu1) stable release version 2.35.

When cross compiled from Ubuntu 20.04, it requires GLIBC 2.4+ on the BBG

$ ldd ./helloworld_20_04 
	linux-vdso.so.1 (0xbef66000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6ded000)
	/lib/ld-linux-armhf.so.3 (0xb6efe000)
$ strings ./helloworld_20_04 | grep GLIB
	GLIBC_2.4
	__cxa_finalize@@GLIBC_2.4
	puts@@GLIBC_2.4
	__libc_start_main@@GLIBC_2.4
	abort@@GLIBC_2.4

When cross compiled from Ubuntu 22.04, it requires GLIBC 2.34+ on the BBG

$ ldd helloworld_22_04
./helloworld_22_04: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.34' not found (required by ./helloworld_22_04)
	linux-vdso.so.1 (0xbeff3000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6e71000)
	/lib/ld-linux-armhf.so.3 (0xb6f82000)
$ strings ./helloworld_22_04 | grep GLIBC
	GLIBC_2.4
	GLIBC_2.34
	__libc_start_main@GLIBC_2.34
	__cxa_finalize@GLIBC_2.4
	puts@GLIBC_2.4
	abort@GLIBC_2.4

BeagleBone Image:
I’m running Debian Bullseye Minimal Image (2022-05-01) Monthly Snapshot

$ sudo beagle-version
	eeprom:[A335BNLTBBG1BBG116046833]
	model:[TI_AM335x_BeagleBone_Green]
	dogtag:[BeagleBoard.org Debian Bullseye Minimal Image 2022-05-01]
	bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2022.04-g4237220b (Apr 08 2022 - 13:42:29 +0000)]:[location: dd MBR]
	UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
	UBOOT: Loaded Overlay:[BB-ADC-00A0.kernel]
	UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0.kernel]
	UBOOT: Loaded Overlay:[M-BB-BBG-00A0.kernel]
	kernel:[5.10.109-ti-r43]
	/boot/uEnv.txt Settings:
	uboot_overlay_options:[enable_uboot_overlays=1]
	uboot_overlay_options:[enable_uboot_cape_universal=1]
	pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
	pkg:[bb-cape-overlays]:[4.14.20210821.0-0~bullseye+20210821]
	pkg:[bb-customizations]:[1.20220325.0-0~bullseye+20220325]
	pkg:[bb-usb-gadgets]:[1.20220316.1-0~bullseye+20220316]
	pkg:[bb-wl18xx-firmware]:[1.20211222.2-0~bullseye+20211222]
	pkg:[kmod]:[28-1]
	WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
	pkg:[firmware-ti-connectivity]:[20210315-3]
	groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal input netdev gpio admin i2c tisdk weston-launch bluetooth cloud9ide]
	cmdline:[console=ttyS0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
	dmesg | grep remote
	[   11.025409] remoteproc remoteproc0: wkup_m3 is available
	[   31.506148] remoteproc remoteproc0: powering up wkup_m3
	[   31.506186] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217148
	[   31.506604] remoteproc remoteproc0: remote processor wkup_m3 is now up
	[   44.794669] remoteproc remoteproc1: 4a334000.pru is available
	[   44.816456] remoteproc remoteproc2: 4a338000.pru is available
	dmesg | grep pru
	[   44.794669] remoteproc remoteproc1: 4a334000.pru is available
	[   44.816456] remoteproc remoteproc2: 4a338000.pru is available
	dmesg | grep pinctrl-single
	[   10.529977] pinctrl-single 44e10800.pinmux: 142 pins, size 568
	dmesg | grep gpio-of-helper
	[   10.531848] gpio-of-helper ocp:cape-universal: Failed to get gpio property of 'P8_03'
	[   10.531880] gpio-of-helper ocp:cape-universal: Failed to create gpio entry
	[   11.204666] gpio-of-helper ocp:cape-universal: Allocated GPIO id=0 name='P8_03'
	[   11.204895] gpio-of-helper ocp:cape-universal: Allocated GPIO id=1 name='P8_04'
	<... SNIP ...>
	[   11.217552] gpio-of-helper ocp:cape-universal: ready
	END

Or just switch to Debian Bullseye 11.x instead of Ubuntu 22.04, thus gcc and glibc will match…

Bullseye is glibc 2.31. Debian -- Details of source package glibc in bullseye

Regards,

Hi Robert,

Thank you for the fast reply and the suggestion. I’ll try that out to see how it will work.

For students who choose to run other distros, is there a suggested way to support this mismatch within a distro? Or is it more a fundamental limitation of of inter-Linux development?

(Also, thank you for your excellent support of BeagleBone over the years! I have long relied on your content!)

Brian.

Hello,
I have the same problem reported by Brian: I tried to use Linaro GCC but libasan.so.4 is too old for BBB, I tried am335x-debian-11.3-xfce-armhf-2022-06-02-4gb but again problem with GLIBC version … A real nightmare ! Is it possible that the only option available is to unistall Ubuntu 22.04 LTS for old version or Debian distro ? Is there no other alternative ?
Thank you in advance for any suggestion.
Regards,
Enzo

Or use docker or qemu/kvm to run Debian in a container to build against…

I have experienced a similar error, on my Ubuntu 22.04 PC. “GLIBC_2.34 not found” when when I use the cross tool chains for aarch64, installed with $ sudo apt install g+±aarch64-linux-gnu. What I have discovered is that if I use pre-built cross aarch64 tool chains for the raspberry PI4 I will not get this error. It has been some time that I downloaded from the link below the tool chains for both arm 32 bit and arrch64 from this site GitHub - abhiTronix/raspberry-pi-cross-compilers: Latest GCC Cross Compiler & Native (ARM & ARM64) CI generated precompiled standalone toolchains for all Raspberry Pis. 🍇.

The one issue I have is that I haven’t made these tools compatible with the Eclipse IDE Scanner Discovery. Eclipse requires the cross tool chains provided by the Ubuntu repository.

I test hello world with gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf and ubuntu 2020.04
and it is ok but I can not solve my problem test opencv cross compile

Ok, so I am new to embedded programming and maybe this is a naive solution (if so please explain why) but have you tried to static link your code? I just had this issue, did a google and saw this comment, but had the idea to static link the library with

arm-linux-gnueabihf-gcc -static hello_bb.c -o hello_bb

it works fine for me