HP-UX Reference (11i v2 07/12) - 1 User Commands A-M (vol 1)
l
ld_ia(1)
Integrity Systems Only
ld_ia(1)
LC_ALL Determines the values for all locale categories and has precedence over
LANG and other
LC_* environment variables.
LC_MESSAGES
Determines the locale that should be used to affect the format and contents of diagnostic
messages written to standard error.
LC_NUMERIC Determines the locale category for numeric formatting.
LC_CTYPE Determines the locale category for character handling functions.
NLSPATH Determines the location of message catalogs for the processing of
LC_MESSAGES .
If any internationalization variable contains an invalid setting,
ld behaves as if all internationalization
variables are set to
C. See environ(5).
In addition, the following environment variable affects
ld:
TMPDIR Specifies a directory for temporary files (see tmpnam(3S)).
BROWSER Specifies the pathname of the browser to display the HP-UX Linker and Libraries Online
User’s Guide when you use the
+help option.
RETURN VALUES
ld returns the following values:
0 Successful completion. The link is successful.
n!=0 Failure. An error has 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
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 -lc
Link a simple Fortran program to use with a symbolic debugger (see wdb(1)). Because the
-o option is not
specified on the command line, the output file name is
a.out.
ld ftn.o -lcl -lisamstub \
-lc /opt/langtools/lib/pa20_64/end.o
Create a shared library:
ld -b -o libfunc.so func1.o func2.o func3.o
Create a shared library with an internal name, and this shared library allows dynamic library searching:
ld -b -o libfoo1.so.1 foo1.o foo2.o +h libfoo1.so.1
ln -s libfoo1.so.1 libfoo1.so
cc -g mytest.c -L . -lfoo1
chatr a.out
...
shared library list:
libfoo1.so.1
If you do not use +h, the shared library does not have an internal name. The linker does not check
whether .so is a symbolic link. It records the library name that it looks at, if it does not have the internal
name.
chatr a.out
...
shared library list:
libfoo1.so
Add $ORIGIN before the shared library name in the shared library list.
ld -dynamic main.o -L /usr/lib/hpux32/ +origin -lc
ld -dynamic main.o +origin /usr/lib/hpux32/libc.so
HP-UX 11i Version 2: December 2007 Update − 18 − Hewlett-Packard Company 515