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-9.2
to 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
export
just adds directories to the end of the path" no, it adds them wherever you tell it to ex.export PATH=/my/special/gcc/path:$PATH
will add to the front – steeldriver Sep 19 '19 at 12:56gcc --version
I still get the old one, whether I change the filename 'gcc-9.2' to 'gcc' or not. – CT1234 Sep 19 '19 at 13:04gcc
is typically just a symbolic link to the current version; if your local installation did not create such a link you would need to do it manually ex.ln -s gcc-9.2 path/to/gcc_9_2/bin/gcc
– steeldriver Sep 19 '19 at 13:12