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
The configure step goes well. The make step fails with the error:
make[2]: Entering directory `<the source directory>/hdf5-1.8.18/c++/src'
CXX H5Exception.lo
H5Exception.cpp:16:18: fatal error: string: No such file or directory
#include <string>
^
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, 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 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 intolibdir
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 bylibgfortran
,libstdc++
, andlibobjc
.
- 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?
-I
include directives in yourCPPFLAGS
like that (i.e. comma separated)? I've always thought you need a separate-I
for each path. FWIW you might consider using gcc'sCPATH
instead - which does take a list of (colon separated) paths.-I
flag takes exactly one directory. If you have multiple include directories, specify each of them separately with-I
.-I/usr/include
to gain access to the header filestring.h
does not help.