Compiling and linking
Multiple compiler suites are available for building and linking application codes, and while they are all share many similarities, it is inevitable that there are also some differences. For example, depending on the type of application, one set of compilers may produce code that performs better than another. Or, certain types of syntax may be accepted by some compilers but not others.
The following compilers are currently available:
Compiling and linking is performed using wrapper scripts ftn, cc, and CC for source code written in Fortran, C, and C++, respectively. These wrappers invoke the appropriate compiler based on the current Programming Environment and produce executables that can be run on the compute nodes. These wrappers are fairly versatile, and automatically link in a wide variety of libraries as necessary, including Cray's Scientific Software Library (libsci) and MPI ( for instance, -lmpi is not required and will cause the link step to fail). In other words, do NOT use mpicc (for instance) to compile MPI codes; the cc or CC wrapper already contains the proper compiler and library invocations.
There are numerous options that can be used to influence the compilation process. Some of these may produce the same behavior across all compilers, but many of them are specific to a particular compiler. Some of the more commonly-used options are listed here (see the compiler man pages or the Cray Application Developer's Environment User's Guide for more detailed information):
-c Produce object file only; do not make executable
-g Include symbol table and other information for debugging
-v Displays verbose compiler output
-r <list opt> Produce a listing file
-o <name> Specify the name of the executable
-O <opt> Controls the level of compiler optimization
-I<dir> Specifies additional location(s) of header files
-L <dir> Specifies additional location(s) of library files
-l<lib> Specifies additional libraries to be linked
The following table provides a comparison of common functionality across compilers.
There are two ways to enable dynamic linking when using the compiler wrapper scripts with any of the supported compilers.
The first way is to use the '-dynamic' flag. This works in principle but the user has to make sure they reproduce the right runtime environment (LD_LIBRARY_PATH) when running the program.
The second method is to use two environment variables that do both: