ROAR User Guide   »   Roar User Guide   »   Compilation- Overview
Feedback [ + ]

Compilation- Overview

You can your own compile code for running on Roar. A basic compilation might look like

gcc -O2 -lm -o hello.out hello.c

where the gnu compiler is used to compile a C code in the file hello.c.

  • gcc Compiler being used
  • -O2 Optimization Flag
  • -lm Link to the math library
  • -o hello.out Output file
  • hello.c Input file

It’s possible to link to pre-compiled libraries that are created by you or that already exist on the system. The module show command can be very useful in determining the locations of the libraries and header files required to compile codes. You can link in a variety of ways.

  • -L (as in Love) Path to a directory containing a library
  • -l (as in love) Library name
  • -I (as in Iowa) Path to header files

Complicated compilations can also be done using a build automation software package such as make, which is available without a module, or cmake, which is available as a module. The general build automation process involves using a Makefile that has:

  • Outputs – the executable/library being created
  • Dependencies – what each output relies on
  • Instructions – how to make/find each dependency

…and can set environment variables. The nomenclature for repeated sections can use regex and so can be very complicated. Information about these tools can be found in online references, such as the make and cmake manuals. Some common pitfalls that the iAsk center sees for using make are:

  • Makefiles require tabs and not spaces at the beginning of indented lines
  • The -j flag and an integer can be used to compile on multiple processors
  • The -f flag can be used to specify the name of the makefile if not Makefile

Some makefiles are configured for the compute environment. You may need to use the command ./configure if there isn’t a make file and configure scripts exist./li>

It is possible to either make the output file directly executable and add the location to your path to call this from anywhere, or to execute the output from the location of the file directly. For our hello example from before, this can be done using the command ./hello.out from the directory in which the executable exists.