libstdc++ is closely bound to GCC/g++. So, if you use a newer GCC/g++, it likely comes with (and uses) a newer version of
libstdc++, e.g. to enable new C++ features. But this means that the resulting binary will need the newer
libstdc++ at runtime too.
Problem is that your Debian 12 base system provides the older version of
libstdc++, which matches its "default" GCC/g++ version and which is what all programs that ship with Debian 12 expect. So, as pointed out before, you would probably have to build the newer version of
libstdc++ (if it hasn't already been built as part of the newer GCC/g++ version)
and make your program use that newer
libstdc++ version
at runtime. Note that you can use
LD_LIBRARY_PATH to make your program load shared libraries from a non-standard directory.
Anyway, if you have Docker installed, then you can start a Debian "Testing" (aka "Trixie") or "Unstable" (aka "Sid") from your current Debian 12 (aka "Bookworm") with a single command
without making any changes to your "host" operating system. For example:
docker run -it debian:testing
This way you get a consistent and fully self-contained build and execution environment inside of the container:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
$ docker run -it debian:sid
Unable to find image 'debian:sid' locally
sid: Pulling from library/debian
b801efa715ff: Pull complete
Digest: sha256:08cc1a90963e48072614d24e816bb659e62ca9db485151785e12331998766627
Status: Downloaded newer image for debian:sid
root@7b5404b2bef9:/# apt-get update && apt-get install -y g++
Hit:1 http://deb.debian.org/debian sid InRelease
[...]
Processing triggers for libc-bin (2.40-2) ...
root@7b5404b2bef9:/# g++ -v
gcc version 14.2.0 (Debian 14.2.0-5)
| |
And, if you don't like it anymore, you can throw the container away in one second 😏