HP-UX Reference (11i v2 04/09) - 1 User Commands A-M (vol 1)

l
ld_pa(1) ld_pa(1)
(For PA-RISC Systems)
If any internationalization variable contains an invalid setting,
ld behaves as if all internationalization
variables are set to
C. See environ (5).
DIAGNOSTICS
ld returns zero when the link is successful. A non-zero return code indicates that an error occurred.
EXAMPLES
Link part of a C program for later processing by
ld. (Note the .o suffix for the output object file; this is
an HP-UX convention for indicating a linkable object file):
ld -r file1.o file2.o -o prog.o
On 32-bit, link a simple FORTRAN program for use with the
dde symbolic debugger (see dde(1)). Output
file name is
a.out since there is no
-o option in the command line.
ld /usr/ccs/lib/crt0.o ftn.o -lcl -lisamstub \
-lc /opt/langtools/lib/end.o
To do this on 64-bit:
ld ftn.o -lcl -lisamstub \
-lc /opt/langtools/lib/pa20_64/end.o
On 64-bit, link a shared bound program in standard mode. Note that crt0.o is not specified because
for shared links, it is no longer necessary.
ld himom.o +std -lc
On 64-bit, link a compatibility mode program.
crt0.o is included because this is an archive link.
ld /opt/langtools/lib/pa20_64/crt0.o himom.o +compat -a archive -lc
Create a shared library:
ld -b -o libfunc.sl func1.o func2.o func3.o
Create a shared library with an internal name:
ld -b -o libfoo1.1 foo1.o foo2.o +h libfoo1.1
ln -s libfoo1.1 libfoo1.sl
cc -g mytest.c -L. -lfoo1
chatr a.out
...
shared library list:
dynamic ./libfoo1.1
If you do not use
+h, the shared library does not have an internal name. The linker does not check
whether .sl is a symbolic link. It records the library name that it looks at, if it does not have the inter-
nal name.
chatr a.out
...
shared library list:
dynamic ./libfoo1.sl
On 32-bit, link a program with
libfunc.sl but use the archive version of the C library. Specify the
immediate binding mode together with the nonfatal modifier and allow verbose diagnostics to be
displayed:
ld /usr/ccs/lib/crt0.o -B immediate -B nonfatal -B verbose \
program.o -L . -lfunc -a archive -lc
To do this on 64-bit:
ld -B immediate -B nonfatal -B verbose \
program.o -L . -lfunc -a archive -lc
On 32-bit, link a Pascal program:
ld /usr/ccs/lib/crt0.o main.o -lcl -lm -lc
Note that in the above examples, /usr/ccs/lib/crt0.o can be replaced by
/opt/langtools/lib/crt0.o.
Section 1486 Hewlett-Packard Company 18 HP-UX 11i Version 2: September 2004