To use the
ld command to link an SMP
program, follow these guidelines:
- Do not use the -e flag to change the
default starting point of the executable output file (__start).
If you use other starting points, your results will be unpredictable.
- Specify the following options and files with the ld command:
- -bh:4, -bpT:0x10000000, -bpD:0x20000000.
- -lxlf before any other libraries or
files on the command line if you are linking any object files compiled
by XL Fortran Version
2.
- The object file that contains the system startup routine:
- crt0.o for a program that was not profiled.
- mcrt0.o for a program that was profiled
with the -p option.
- gcrt0.o for a program that was profiled
with the -pg option.
- Link with the startup files in /usr/lib.
- Compiler and system libraries, in the following order:
- For POSIX pthreads Draft 7 support:
-lxlfpthrds_compat, -lxlf90, -lxlopt, -lxlf, -lxlsmp,-lpthreads_compat, -lpthreads, -lm, -lc
- For POSIX pthreads 1003.1-1996 standard support:
-lxlf90, -lxlopt, -lxlf, -lxlsmp, -lpthreads, -lm, -lc
- You only need to specify -lxlsmp if
you are compiling with -qsmp.
- If you use the -qautodbl option, specify
some extra libraries that are listed in -qautodbl.
- If you use the -qpdf1 compiler
option, specify -lxlipa.
- If you use the -qhot=vector suboption,
specify -lxlopt.
If
you had a program called mytest and you
wanted to obtain access to the functions in the 1003.1-1996 standard
POSIX pthreads API, you
would link with the
libpthreads.a library,
using something similar to the following command:
ld -bh:4 -bpT:0x10000000 -bpD:0x20000000 /lib/crt0.o mytest.o -lxlf90
-lxlopt -lxlf -lxlsmp -lpthreads -lm -lc -o mytest
The 1003.1-1996 standard is not fully compatible with Draft 7.
If you have programs that require the Draft 7 interface, link your
programs with the
libpthreads_compat.a and
libxlfpthrds_compat.a libraries
(which provide compatibility support) followed by the
libpthreads.a library.
For example, if you have a program called mytest that
was written to use the Draft 7 interface, you
would use something similar to the following command: ld -bh:4 -bpT:0x10000000 -bpD:0x20000000 /lib/crt0.o mytest.o
-lxlfpthrds_compat -lxlf90 -lxlopt -lxlf -lxlsmp
-lpthreads_compat -lpthreads -lm -lc -o mytest
The configuration file /opt/IBM/xlf/15.1.0/etc/xlf.cfg lists
these default libraries and linker options. By doing a sample compilation
with the -# option, you can see exactly
how the compiler would run the linker.
See the AIX® Commands
Reference, Volumes 1 - 6 for a description of the linker options.