Using GCC

What versions of GCC are available?

In addition to the default GCC provided by the OS, we have several older and newer versions of GCC compiler available. To see what versions of GCC are available:

$ module avail gcc
------------------- /usr/local/modules -----------------------------------
gcc/6.5.0  gcc/7.4.0  gcc/8.2.0  gcc/9.3.0  gcc/10.2.0  gcc/11.2.0

To load the latest version of GCC:

$ module load gcc

Or to load a specific version of GCC:

$ module load gcc/11.2.0

Confirm:

$ module list
Currently Loaded Modulefiles:
 1) gcc/11.2.0

And:

$ gcc --version
gcc (GCC) 11.2.0
How can I switch to a different version of GCC?

If you have loaded a GCC version and would like to switch to a different version:

$ module switch gcc/<VERSION>