I have access to a cluster with CentOS 7, which has gcc installed. Unfortunately, gcc version is pretty old (4.8), and is reported incompatible by some of the Python packages I am using, requiring version >5.0. However, since I do not have root privilege, I cannot easily install/delete anything there.

I have followed some answers from stack exchange, installing the gcc 8.4 from source code. The make install seem to be successful.

Then, I have followed the accepted answer to one question here (How to set the default gcc version for only one user?) to change the default. However, it does not work for me.

  1. The gcc 8.4 is located at $HOME/gcc_8_4 with a (seemingly properly working) symlink $HOME/bin/gcc.
  2. The gcc 4.8 is located at /usr/local/bin.
  3. $HOME/bin comes before /usr/local/bin in the PATH, as written in the mentioned answer.
  4. If I call ./gcc --version from $HOME/bin/gcc/bin directory, I get the version 8.4. If I call it as gcc --version from any location, I still get 4.8.

So, has something changed since that answer was posted? Why the 4.8 version is taken as a default one despite it coming after 8.4 version in the PATH? Is there any way to fix that?

  • which gcc; echo $PATH? Commented Apr 5, 2021 at 22:59
  • @ArtemS.Tashkinov /usr/bin/gcc and /home/iegorval/bin:/home/iegorval/miniconda3/envs/smaln/bin:/home/iegorval/miniconda3/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
    – Valeria
    Commented Apr 5, 2021 at 23:21

1 Answer 1


Not enough reputation to comment, but in your point 4, it says $HOME/bin/gcc/bin. Is that correct, or did you mean $HOME/bin/?

If the former is correct, then your PATH is obviously incorrect, since it doesn't contain the gcc/bin subdirectory, and it looks like you may have added an extra layer of subdirectories (the gcc/ subdir) to $HOME/bin when symlinking.

In that case, either remove the extra layer (symlink all executables from $HOME/gcc_8_4/ directory into $HOME/bin, or adjust your PATH to include $HOME/bin/gcc/bin.

  • The directory structure is $HOME -> bin -> gcc -> (bin, include, lib, lib64, libexec, share). So, I add $HOME/bin to the path, which contains gcc directory symlink. My PATH is then /home/iegorval/bin:/home/iegorval/miniconda3/envs/smaln/bin:/home/iegorval/miniconda3/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin.
    – Valeria
    Commented Apr 6, 2021 at 1:08
  • The executable gcc is still located in a subsubdirectory of $HOME/bin. Your shell will not find it until you add that directory to your PATH.
    – 9769953
    Commented Apr 6, 2021 at 1:11
  • I guess I have a very unlucky choice of names. gcc, which is located in $HOME/bin is not an executable, it is a symlink to the gcc-8.4 folder, located elsewhere. The executable of gcc is located in $HOME/bin/gcc/bin, or, without a symlink, in [path-to-gcc-8.4]/gcc-8.4/bin.
    – Valeria
    Commented Apr 6, 2021 at 1:15
  • That is my point! Just add $HOME/bin/gcc/bin to your PATH.
    – 9769953
    Commented Apr 6, 2021 at 1:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .