pgc++ --c++11 main.cpp -o test
"main.cpp", line 8: error: namespace "std" has no member "to_string"
std::string f_str = std::to_string(f);
^
1 error detected in the compilation of "main.cpp".
nehalem01% pgc++ -o test test.cpp
“test.cpp”, line 8: error: namespace “std” has no member “to_string”
std::string f_str = std::to_string(f);
^
1 error detected in the compilation of “test.cpp”.
nehalem01% pgc++ -o test test.cpp -std=c++11
“test.cpp”, line 8: error: namespace “std” has no member “to_string”
std::string f_str = std::to_string(f);
^
1 error detected in the compilation of “test.cpp”.
So it fails when g++ does not also support the newer standards.
Unfortunately I’m working in a machine with ‘modules’ and moving from g++ < 4.9 to g++ > 5.2 doesn’t seem to work:
$ module purge
$ module load gcc/4.9.4
load gcc/4.9.4 (PATH, MANPATH, LD_LIBRARY_PATH)
$ g++ --version
g++ (GCC) 4.9.4
$ g++ -std=c++11 test.cpp -o test
$ $ ./test
f_str: 23.430000
$ module load pgi/17.4
load pgi/17.4 (PATH, MANPATH, LD_LIBRARY_PATH, LM_LICENSE_FILE)
$ pgc++ --c++11 test.cpp -o test
"test.cpp", line 8: error: namespace "std" has no member "to_string"
std::string f_str = std::to_string(f);
^
1 error detected in the compilation of "test.cpp".
Same happens if I load a newer g++ version like 6 or 7.
I suspect that pgc++ is ignoring the current loaded g++ version and is using the default one from the system. Is this possible? When does pgc++ detect the g++ version? At run time or at installation time?
makelocalrc does not handle the non-default gcc/g++ versions
well. Those switches are more for what g++ and gcc and gfortran
are named, and not a path to the different versions.
If you look at
pgc++ -v test.cpp -std=c++11
and
g++ -v test.cpp -std=c++11
you will probably see that pgc++ uses different assemblers and other
components than the version of g++ is using.
If you have ‘locate’ on your linux system, you can do the following
If you have not installed 17.4 as a ‘Network Install’, remove it and
reinstall selecting a Network type.
cd $PGI/linux86-64/17.4/bin
chmod +x ./addlocalrc
And then run ‘addlocalrc’
and it will create a localrc.something for each gcc version it finds.
Each time you wish to use a version of gcc, find its localrc.xxx
file and
setenv PGI_LOCALRC /full/path/to/localrc.xxx
and the compilers should now use the newer gcc.
The network install allows for multiple gcc versions, and
addlocalrc creates any localrc files you will need. The two together
means a single install can handle multiple gcc versions.
This process is meant for multiple platform/linux types to share
a common PGI installation.
Does addlocalrc have flags to specify other gcc’s?
$
./addlocalrc
Usage: addlocalrc [release_dir]
The release_dir is defaulting to /home/myhome
Do you want to continue? (y/n) y
Only one working gcc executable was found on this system
It was found in the default location, /usr/bin/gcc
Do you want to continue? (y/n) y
This script has located one or more gcc executables.
For each gcc executable found, you have the option to configure
the PGI compilers for use with those header files and libraries by
generating a GNU-version-specific localrc file.
The localrc file used by pgcc and pgc++ can be controlled by using
the PGI_LOCALRC environment variable at compilation time.
This script can be rerun at any time, for instance, after a new
version of the GNU toolchain has been installed.
For each GNU executable found, choose whether to proceed with the
configuration, skip that version, or quit this script.
Configuring PGI for gcc found at /usr/bin/gcc (default), GNU version 4.4.7
Proceed, Skip, or Quit? (p/s/q)
$ gcc --version
gcc (GCC) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
...
$ which gcc
/apps/GCC/4.9.4/bin/gcc
addlocalrc can’t see the gcc version I want. It’s still picking the gcc from the system.