Author Topic: Need to statically link on Pi Bookworm (32 and 64 bit)  (Read 653 times)

SteveS

  • Posts: 22
I have a bit of an issue. I have been happily using BASS on Raspberry Pi for years, 32-bit and 64-bit.

However, I have now moved my development to Bookworm (latest release of the RPi OS) from Buster.
Unfortunately, my binaries no longer run on Buster machines (of which I have many, because I am using PiZero boards with Pimoroni PirateAmp boards in each room), because having built on Bookworm, it will not run on Buster as the versions of glibc differ.

The advice I received from the Pi Forum was to statically link. However, this isn't possible, because I don't have a static library for BASS, and I can't write a shim to provide wrapper functions and load it via the shim at runtime, because DL requires using the shared glibc version...

So it looks like I am stuck, and will have to revert to Buster, or upgrade all the player hardware to Bookworm, unless anyone knows how I can resolve this.

Ian @ un4seen

  • Administrator
  • Posts: 26178
It may be possible to avoid the later glibc version dependency by requesting older versions of the affected symbols. You can run "objdump -T <filename>" to find out what symbols are requiring the later glibc version, and then replace them.

You can find an example and details of the idea here:

   https://github.com/wheybags/glibc_version_header

SteveS

  • Posts: 22
Hi Ian

Thanks for the suggestion. I have looked at it, and discovered that there are other "issues" which would stop me statically linking, such as the availability of other static libraries for some of the other libraries I use.

The advice I got was to effectively cross-compile, but as I am not using any of my software outside of my own network, I decided in the end to bite the bullet and upgrade all the affected machines to bookworm. Since they are all running the "lite" version of the Pi OS, I can create one master SD image, boot it, apply upgrades and configure everything except the machine name, and then clone the card, so this is substantially easier!

Out of interest, how do you create the shared libraries? Are you cross-compiling using an "older" toolchain?

Ian @ un4seen

  • Administrator
  • Posts: 26178
Yes, a cross-compiler would probably be the best way to support older systems while building on a newer one. The BASS libraries are built like that, using a custom GCC 9.5 build that targets glibc 2.13*, but even older versions are supported because BASS doesn't actually use any symbols newer than glibc 2.3.3.

*glibc 2.17 is targetted on aarch64, as that seems to be the oldest version used there.