Dynamically Linking Applications

By default, on Shaheen II Cray XC40, compiling and linking libraries to build an application will make use of static linking, which is recommended for most applications. However, using dynamic libraries is necessary for some applications. In this case, users can link applications dynamically by either setting the environment variable CRAYPE_LINK_TYPE to dynamic or by adding the -dynamic flag during linking.

  • Example of building program with dynamic linking, export the environment variable and compile your code normally.
export CRAYPE_LINK_TYPE=dynamic
ftn -o my_exe_dynamic  my_program.f90
  • Same example by using linker flag:
ftn -dynamic -o my_exe_dynamic my_program.f90

At runtime you also need to export CRAY_ROOTFS=DSL in your job script.
Please note that using dynamically linked applications does have a performance impact especially with a large number of processes.  This is due to the runtime linking process and symbol lookup in the shared objects during the startup of the program or when the loading of the dynamically loaded library is called.