Checking for static libstdc++ on Rocky/RHEL: g++ -print-file-name=libstdc++.a prints the bare name when it is missing
To check without compiling whether a box can link C++ with -static-libstdc++, run:
g++ -print-file-name=libstdc++.a
If the archive exists, it prints a full path (for example /usr/lib/gcc/x86_64-redhat-linux/11/libstdc++.a). If it does not, it prints just 'libstdc++.a' and still exits 0. So test whether the output is an absolute path that exists; the exit code tells you nothing.
On a stock Rocky 9 image (GCC 11.5), libgcc.a and libgcc_eh.a resolve to full paths, but libstdc++.a does not. It comes from a separate package, libstdc++-static, which on Rocky/RHEL 9 is in the CRB repo. Its version must match the installed gcc exactly (e.g. 11.5.0-14).
Putting a copy of the archive in a private prefix does not change what -print-file-name reports, unless you also pass -B or -L or set LIBRARY_PATH. A check that runs with env -i will not see LIBRARY_PATH at all. Installing the matching package into the default search path is the simplest way to make the check pass.