Resolving library version incompatibility for libstdc++.so on recent Ubuntu versions

On an x86_64 computer running Ubuntu 22.04 (and, I think, earlier releases too) the version of libstdc++.so in /usr/lib/x86_64-linux-gnu/ is libstdc++.so.6.0.30. Julia, even when compiled from sources, provides ./usr/lib/libstdc++.so.6.0.29. The result is that operations like pre-compiling the GLMakie package fail with obscure error messages. Also certain R or Python packages that incorporate compiled C++ code fail inside of RCall or PyCall, again with error messages that may puzzle new users.

I have used two different fixes, both of which seem a bit hackish. One is brute force - changing the symbolic links in the julia sources ./usr/lib directory for libstdc++.so and libstdc++.so.6 to point to the system version, libstdc++.so.6.0.30, instead of the local version, libstdc++.so.6.0.29. An alternative, which I saw in Miguel Raz Guzmán Macedo’s JuliaCon workshop on the REPL is to call Julia as

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so julia

Is there a recommended way of overriding the version of libstdc++.so that is shipped with Julia?

After discussing this with @ararslan, I think the Make flag to set would be USE_SYSTEM_LIBSTDCXX, but it doesn’t seem to exist. It might be worth a PR adding it.

Related: GLIBCXX version not found