What follows is one avenue to a solution. I am indebted to [Thomas Dickey answer](https://unix.stackexchange.com/a/346134/132913) for having put me in the right direction. ### Issue # The problem is that the custom-installed compiler gcc 6.3.0 cannot find the files of the `libstdc++` family contained within `/usr/include/` in the Ubuntu distribution. ### Cause # At point of installation, the configure file for gcc 6.3.0 itself silently followed the default specification as for the target directory where to find local (previously installed) header files. This default is `/usr/local/include/`. See https://gcc.gnu.org/install/configure.html for details. ### Fix # The compiler reinstalled with the `./configure --with-local-prefix=/usr` has created a new gcc that is able to fetch the required files where Ubuntu has put them. No further adjustement of the `CPPFLAGS` is needed with respect to what has been shown in the question. However, the setting `--with-local-prefix=/usr` is discouraged (see quote in https://unix.stackexchange.com/a/348868/132913), so this is a workaround. ### Check # The empirical test for this strategy is that the `make` of HDF 1.8.18 proceeds where it once got stranded. All tests in the `make check` are passed successfully. ### Alternatives I have note explored (yet) the other avenue of installing a fresh `libstdc++` library that serves specifically the custom install of gcc (switch `--enable-version-specific-runtime-libs`). I have raised this possibility in the question frame above in search of cues. That might well be a more robust solution. The thread remains open for the moment. Thanks for contributing/editing