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.