Dynamic and static linking
IBM® Open XL Fortran allows your programs to take advantage of the operating system facilities for both dynamic and static linking.
- Dynamic linking means that the code for some external routines is located and loaded when the
program is first run. When you compile a program that uses shared libraries, the shared libraries
are dynamically linked to your program by default.
Dynamically linked programs take up less disk space and less virtual memory if more than one program uses the routines in the shared libraries. During linking, there are less chances for naming conflicts with library routines or external data objects because only exported symbols are visible outside a shared library. They may perform better than statically linked programs if several programs use the same shared routines at the same time. They also allow you to upgrade the routines in the shared libraries without relinking.
Because this form of linking is the default, you need no additional options to turn it on.
- Static linking means that the code for all routines called by your program becomes part of the
executable file.
Statically linked programs can be moved to and run on systems without the IBM Open XL Fortran libraries. They may perform better than dynamically linked programs if they make many calls to library routines or call many small routines. There are more chances for naming conflicts with library routines or external data objects because all global symbols are visible outside a static library. They also may not work if you compile them on one level of the operating system and run them on a different level of the operating system.
You can use -b linker options on the compiler command line to create statically linked object files:
You must also specify -bI:/usr/lib/threads.exp when you are statically linking with the xlf_r, xlf90_r, xlf95_r, xlf2003_r, or xlf2008_r command.xlf95 -bnso -bI:/usr/lib/syscalls.exp -bI:/usr/lib/aio.exp file1.f file2.f -lcryptThe -bnso option places the library procedures that your program references into the program's object file.
An alternative that requires less disk space is to link any IBM Open XL Fortran libraries statically but to leave references to other system libraries dynamic. This example statically links just the IBM Open XL Fortran libraries:# Build a temporary object from the Fortran library: ld -r -o libtmp.o -bnso -lxlf90 # Build the application with this object on the command line: xlf95 -o appl appl1.o appl2.o libtmp.o