gcc compilation terminated with "fatal error: string: No such file or directory #include <string>"
5
votes
2
answers
60311
views
My situation.
uname -a
gives Linux computer2 4.4.0-62-generic #83~14.04.1-Ubuntu SMP Wed Jan 18 18:10:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
I am trying to install **HDF5 1.8.18** with **GNU make 3.81** invoking **gcc 6.3.0**. I have successfully installed this gcc 6.3.0 alongside the version 4.8.4 that is shipped with the Ubuntu distribution.
My gcc 6.3.0 lives in /opt/gcc/6_3_0/
. I use the following script to configure and pass on the commands, libraries and headers in non-standard directories:
export FC='/opt/gcc/6_3_0/bin/gfortran-6.3.0' # probably unnecessary
export CC='/opt/gcc/6_3_0/bin/gcc-6.3.0'
export CXX='/opt/gcc/6_3_0/bin/g++-6.3.0'
export CPP='/opt/gcc/6_3_0/bin/cpp-6.3.0'
export LDFLAGS='-L/opt/gcc/6_3_0/lib -L/opt/gcc/6_3_0/lib64'
export CPPFLAGS='-I/opt/gcc/6_3_0/include -I/opt/gcc/6_3_0/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include'
./configure \
--prefix=${insdir} \
--with-zlib=${zlibdir}/include,${zlibdir}/lib \
--enable-fortran \
--enable-cxx
where ${insdir}
is an installation directory, ${zlibdir}
is where zlib lives and the other switches are standards as per the [installation guidelines](https://support.hdfgroup.org/ftp/HDF5/current18/src/unpacked/release_docs/INSTALL)
The configure step goes well. The make step fails with the error:
make: Entering directory `/hdf5-1.8.18/c++/src'
CXX H5Exception.lo
H5Exception.cpp:16:18: fatal error: string: No such file or directory
#include
^
compilation terminated
If I understand it correctly, some header file is missing, and of a basic nature.
- Where should I get it from?
- Is there any flaw in the names and values of the environment variables?
StackExchange contains a host of [posts on this error](https://stackexchange.com/search?q=fatal+error%3A+string%3A+No+such+file+or+directory) , but they seem to be mostly related to coding exercises. My aim is not to edit codes, rather to compile source codes successfully with my vanilla gcc 6.3.0.
**Updated question**
In the light of the helpful comments and Thomas Dickey's answer below, it appears that a promising avenue is to install matching versions of libstdc++
and gcc
. I have searched around in the [GCC website](https://gcc.gnu.org/install/configure.html) and it appears that one can configure gcc
with the following switch
> --enable-version-specific-runtime-libs
>
> Specify that runtime libraries should be installed in the compiler specific subdirectory (libdir/gcc
) rather than the usual places. **In addition, libstdc++
's include files will be installed into libdir
unless you overruled it by using --with-gxx-include-dir=dirname
.** Using this option is particularly useful if you intend to use several versions of GCC in parallel. This is currently supported by libgfortran
, libstdc++
, and libobjc
.
- Is this pointing in the right direction?
- Where would I be supposed to find the libstdc++'s include files that are distributed alongside the source of gcc, if this is switch is not used?
Asked by XavierStuvw
(1179 rep)
Feb 19, 2017, 04:52 PM
Last activity: Jun 6, 2023, 06:49 PM
Last activity: Jun 6, 2023, 06:49 PM