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):
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:
so that the application is linked dynamically and the paths to the module libraries are preserved using the '--rpath' linker option.
You will have to still pass the correct '-L' and '-Wl,--rpath,PATH_TO_LIB' options for third party libraries that are not provided by modules since the compiler wrapper does not know about these libraries.