GNU Compiler Collection (gcc)
Guidance last updated: 20 October 2026
The GNU Compiler Collection (gcc) is a widely used, free collection of compilers for C (gcc), C++ (g++) and Fortran (gfortran).
It is possible to switch versions of the gcc compiler suite using modules.
Usage
After connecting to Stanage (see Establishing a SSH connection), start an interactive session:
salloc
Choose the compiler version by running one of the following lines:
module load GCC/15.2.0
module load GCC/14.3.0
module load GCC/14.2.0
module load GCC/13.3.0
module load GCC/13.2.0
module load GCC/12.3.0
module load GCC/12.2.0
module load GCC/15.2.0
module load GCC/14.3.0
module load GCC/14.2.0
module load GCC/13.2.0
module load GCC/12.3.0
module load GCC/12.2.0
For the examples below, load GCC/15.2.0. Confirm the compiler versions with:
gcc --version
g++ --version
gfortran --version
Use a matching toolchain when linking against module-provided libraries; see matching foss toolchains.
Compile and run a program
The following examples sum the integers from 1 to 100 and print 5050.
Choose one language and save its source file in your working directory.
Save as sum.c:
#include <stdio.h>
int main(void) {
int total = 0;
for (int i = 1; i <= 100; ++i) total += i;
printf("%d\n", total);
return 0;
}
Compile and run:
gcc -O2 -Wall -Wextra -std=c17 sum.c -o sum_c
./sum_c
Save as sum.cpp:
#include <iostream>
int main() {
int total = 0;
for (int i = 1; i <= 100; ++i) total += i;
std::cout << total << '\n';
return 0;
}
Compile and run:
g++ -O2 -Wall -Wextra -std=c++17 sum.cpp -o sum_cpp
./sum_cpp
Save as sum.f90:
program sum_numbers
implicit none
integer :: i, total
total = 0
do i = 1, 100
total = total + i
end do
print '(I0)', total
end program sum_numbers
Compile and run:
gfortran -O2 -Wall -Wextra sum.f90 -o sum_fortran
./sum_fortran
-O2 enables optimisation, -Wall -Wextra enables compiler warnings,
and -o names the executable. The C and C++ commands explicitly select
language standards.
Example batch submission
Save the C source above as sum.c and the following example batch submission
script as gcc.slurm in the same directory:
#!/bin/bash
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=1000
#SBATCH --time=00:05:00
set -e
export SLURM_EXPORT_ENV=ALL
module load GCC/15.2.0
gcc -O2 -Wall -Wextra -std=c17 sum.c -o sum_c
srun ./sum_c
Submit it from that directory with:
sbatch gcc.slurm
Language support
Which version(s) of GCC support which features of the C99 and C11 standards?
Which version(s) of GCC support which features of the C++98, C++11, C++14 and C++17 standards?
Documentation
man pages are available on the system.
Once you have loaded the required version of gcc, type
man gcc
Installation notes
GCC was installed using Easybuild, build details can be found in $EBROOTGCC/easybuild with a given module loaded.