We’re building a project consisting of 2 shared libraries libProduct
and libHelper
. libProduct
depends on libHelper
. We are using a pretty new GCC toolchain (12) for the Linux build in order to leverage C++20 features in our codebase.
Now we need to ship our libraries to a user using an older Raspbian/Debian. First of all he wants to link his application to libProduct
, but he also wants to swap out libHelper
. The problem is that he uses a much older toolchain – the one coming with Raspbian.
We tried to link our libraries with -static-libstc++
and -static-libgcc
and were hoping that this would create more or less self-containing shared libraries, but the observation is:
libHelper
contains a lot of symbols from libstdc++ – that’s expectedlibProduct
uses the libstdc++ symbols fromlibHelper
rather than including own copies of the symbols- the user could not easily swap out
libHelper
with his own build because his toolchain might not provide some needed symbols in its libstdc++.
How can we solve this and achieve our goals:
- We want to use a new toolchain and libstdc++
- We don’t want to force users to upgrade their toolchain
I know that statically linking libstdc++ to shared libraries is discouraged for various reasons. Still I would like to test it at least. But maybe there’s a better alternative.