Skip to content

GNU Compiler Collection (GCC)

The GNU Compiler Collection (GCC) consists of the following tools to compile C, C++ and Fortran programs:

gcc GNU C compiler
g++ GNU C++ compiler
gfortran GNU Fortran compiler
gccgo GNU Go Compiler

Versions and Availability

We generally support the last three major versions. You can get a list of available versions using the command module avail compiler/gnu.

Environment variables

To see a list of all environment variables set by the modules use the command module show compiler/gnu/version.


setenv("CFLAGS","-O2 -march=native")
setenv("CXXFLAGS","-O2 -march=native")
setenv("FFLAGS","-O2 -march=native")
setenv("FCFLAGS","-O2 -march=native")


The official documentation can be found here. For a detailed lists of the different program options you can also consult the man pages installed on HoreKa:

$ man gcc
$ man g++
$ man gfortran


You can turn on various optimization options to enhance the performance of your program. Which options are the best depends on the specific program and can be determined by benchmarking your code. A command which gives good performance and a decent file size is

$ gcc -march=native -O2 ex.c -o ex

There are more aggressive optimization flags but the compiled programs can get quite large and the compilation process will probably take much longer. Moreover it can happen that the so compiled program is even slower. Such a command would be for example

$ gcc -march=native -O3 ex.c -o ex

For a complete list of all the optimization options execute

$ gcc --help=optimizers

Last update: September 23, 2022