CRC Wiki
CRC Wiki
Log in

GCC Compiler Suite

From CRC Wiki

General Description

The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Java, Ada, and Go, as well as libraries for these languages (libstdc++, libgcj,...). GCC was originally written as the compiler for the GNU operating system.

The GNU system was developed to be 100% free software...free in the sense that it respects the user's freedom.

Choosing a version

The can check the version of GCC with this command:

 gcc --version

We maintain several versions via the module command. To see which other versions are available:

 module avail gcc

You can switch to one of these versions by loading it:

 module load gcc/x.y


Basic Usage

Basic source code compilation usage is as follows:

C

gcc hello.c -o hello

Fortran

gfortran hello.f90 -o hello

C++

g++ hello.cpp -o hello

Useful Compilation Options

-Wall

Display all warnings during compilation

-O3

Compile at higher optimization level

-g

Enable debug symbols in executable (required for debuggers)

-ftrapv

Cause the program to abort on signed integer overflow (formally "undefined behaviour" in C).

Further Information

See the official website: GNU Compiler Collection