I have a user account on RHEL 6.7. The built-in gcc does not support c++11, so I am trying to install my a more recent gcc. I have run configure with --prefix=$HOME/dependencies/gcc , make, make install, and updated my environment variables:
declare -x LIBRARY_PATH="~/dependencies/gcc/lib64:$LIBRARY_PATH"
declare -x PATH="~/dependencies/gcc/bin/:$PATH"
gcc -v now shows the updated version (either 4.9.4 or 5.5.0, I have tried both), and which gcc shows the expected output:
[user@host ~]$ which gcc
~/dependencies/gcc/bin/gcc
The problem is the following:
[user@host ~]$ g++ -std=c++11 -o test test.cpp
g++: error trying to exec 'cc1plus': execvp: No such file or directory
[user@host ~]$ ~/dependencies/gcc/bin/g++ -std=c++11 -o test test.cpp
[user@host ~]$
I wonder why I have to give the full path to g++ to make this work. I could not debug this with strace, since strace g++ runs the version from /usr/bin. Any ideas?
Update after adding a symlink as suggested by Knud Larsen, I ran strace strace g++55 and noticed this line:
stat("~/dependencies/gcc/bin/g++55", 0x7ffcf17f9530) = -1 ENOENT (No such file or directory)
After replacing ~ in PATH and LIBRARY_PATH with /home/user, everything works well.
gccversions through/usr/sbin/alternatives --config gcc– GAD3R May 08 '18 at 14:28which g++– ajeh May 08 '18 at 16:48ln -s gcc gcc55andln -s g++ g++55... And : only use the new names in commands. Then hopefully g++55 will use the rightcc1plus... ( The symlinks can have any locatation, e.g./home/[name]/bin/{ gcc55, g++55 }.) The ideal configuration for gcc would have been option--program-suffix=55. I.e. an extra gcc shoudn't be named gcc. – Knud Larsen May 08 '18 at 16:53statyourgccandg++. I have a feeling that they are symlinks. – ajeh May 08 '18 at 17:25~in paths is not fully supported, see the update. I yet have to understand why, using~worked for me before. – LinAlg May 08 '18 at 17:28/home/username/dependenices/gccin thePATHit works? – ajeh May 08 '18 at 18:26