I have a new version of gcc installed from source in my directory on a larger computer system which has another (older) version used as default. I have a few programs I need to compile using this newer version so I need to switch the version my system automatically uses somehow.
The newer gcc verion has a set of executables in
gcc_9_2/bin/ that look like:
g++-9.2 gcc-9.2 gfortran-9.2
i.e with version numbers attached.
The simplest thing that occurred to me was to change
$PATH so that the directory containing the newer versions was searched first, but I don't know how to do that and
export just adds directories to the end of the path (which won't work). Then remove the version numbers from the executables such as
gcc and similar, though I'd be surprised if this does not cause problems.
I've looked at the answers in How to choose the default gcc and g++ version? but the first response requires sudo permissions (which I don't posses) and the second requires me to
rm /usr/bin/gcc which again, I don't have permission to do.
TLDR: When I type
gcc my computer uses one version of gcc, I need it to use a different version and I don't have permission to edit the directory where the old version is installed