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

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

-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

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.

Direct dependencies for latest version of GCC