Search

link to homepage

Institute for Advanced Simulation (IAS)

Navigation and service


Shared Libraries and Dynamic Executables

Blue Gene/P offers the possibility to create shared libraries and dynamic executables.

WARNING: In general it is not recommended to use shared libraries on JUGENE because loading the shared libraries can delay the startup of the dynamically linked application considerably, especially when using large partitions (8 racks or more). Therefore, please use shared libraries *only* if there is no other possiblity.

In the following we describe how to generate shared libraries and create dynamic executables using the IBM XL compiler suite for C and Fortran codes. In case you would like to use the gcc compiler suite, please see the BlueGene/P Application Development Redbook for further details.

Shared Libraries and dynamic Executables in C

You need to compile the library functions unsing the compiler option -qpic to generate position independent code. To generate the shared library use the options -qmkshrobj and -qnostaticlink.

Example how to create a shared library (C):

mpixlc -c -qpic library_function.cmpixlc -qmkshrobj -qnostaticlink -o libmys_c.so library_function.o

In order to create the dynamic executable you need to compile the code with -qpic and link it with the shared libraries using the -qnostaticlink -qnostaticlink=libgcc options. Use the linker option -rpath to specify the directory where the shared libraries or objects will be located during execution of the code. Alternatively, you can set the LD_LIBRARY_PATH variable to the appropriate directory before calling the executable.

Example how to create a dynamic executable (C):

mpixlc -c -qpic dyn_c.cmpixlc -o dyn_c.x dyn_c.o
-qpic -Wl,-rpath=path-to-shared-lib -Lpath-to-shared-lib
-lmys_c -qnostaticlink -qnostaticlink=libgcc


Shared Libraries and dynamic Executables in Fortran:

You need to compile the library functions unsing the compiler option -qpic to generate position independent code. To generate the shared library use the ld linker command with the option -shared.

Example how to create a shared library (Fortran):

mpixlf90 -c -qpic library_function.f90ld -o libmys_fortran.so library_function.o -shared

In order to create the dynamic executable you need to compile the code with -qpic and link it with the shared libraries using the -dy linker option. Use the linker option -rpath to specify the directory where the shared libraries or objects will be located during execution of the code. Alternatively, you can set the LD_LIBRARY_PATH variable to the appropriate directory before calling the executable.

Example how to create a dynamic executable (Fortran):

mpixlf90 -o dyn_fortran.x dyn_fortran.f90
-qpic -Wl,-dy -Wl,-rpath=path-to-shared-library
-Lpath-to-shared-lib -lmys_fortran


Servicemeu

Homepage