Updating /usr/include/c++ in CentOS-7

Viewed 824

I have installed the devtoolset-10 package on CentOS 7 and run the /opt/rh/devtoolset-10/enable script so that now when I do this:

g++ --version

I get this:

g++ (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)

Great. Trouble is, the headers under /usr/include/c++ still point to ye olde libstdc++-4.8.5. That is, if I do ls in /usr/include/c++, all I see is:

bash-4.2$ ls /usr/include/c++
4.8.2  4.8.5

What is the magic incantation to "enable" libstdc++-10 to be the default system C++ stdlib?

4 Answers

devtoolset-10

Every g++ comes with it's own headers. /usr/include/c++/4.8* is for 4.8.5 only.

devtoolset-10: g++ version 10 is using the headers at /opt/rh/devtoolset-10/root/usr/include/c++/10

"enable" libstdc++-10

There is no shared library "libstdc++-10". There is /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/{ libstdc++.a, libstdc++.so } , where libstdc++.so is a ~200B text file.

I guess the users are supposed to query gcc for the include path. On my CentOS /usr/include/c++ is not a symlink, and is not supposed to point anywhere, but one can work around that using update-alternatives (I did that only for the compiler itself only, though). Might be overriden by an update, but those don't happen often enough on CentOS.

What is the magic incantation to "enable" libstdc++-10 to be the default system C++ stdlib?

Developer Toolset uses a hybrid linkage model. This means that it does not come with its own libstdc++.so.6, but uses the system version as far as possible. The missing parts are linked statically. This is achieved by the linker script that Knud Larsen mentions.

If you want to compile using headers from the latest C++ compiler you have on Centos7:

  1. Remove your build directory
  2. Export your chosen compiler specifically: export CXX=g++

Thanks to this comment from github:

Related