Kenwood HP 9000 Personal Computer User Manual


 
58 Chapter 3
Linker Tasks
Using Linker commands
Augmenting the Default Linker Search Path with -L
The -L option to ld also allows you to add additional directories to the
search path. If -L libpath is specified, ld searches the libpath directory
before the default places.
For example, suppose you have a locally developed version of libc,
which resides in the directory /usr/local/lib. To make ld find this
version of libc before the default libc, use the -L option as follows:
$ ld /opt/langtools/lib/crt0.o prog.o -L /usr/local/lib -lc
Multiple -L options can be specified. For example, to search
/usr/contrib/lib and /usr/local/lib before the default places:
$ ld /opt/langtools/lib/crt0.o prog.o -L /usr/contrib/lib \
-L /usr/local/lib -lc
If LPATH is set, then the -L option specifies the directories to search
before the directories specified in LPATH.
Changing the Default Shared Library Binding
with -B
You might want to force immediate binding — that is, force all
routines and data to be bound at startup time. With immediate binding,
the overhead of binding occurs only at program startup, rather than
across the program's execution. One possibly useful characteristic of
immediate binding is that it causes any possible unresolved symbols to
be detected at startup time, rather than during program execution.
Another use of immediate binding is to get better interactive
performance, if you don't mind program startup taking a little longer.
Example Using -B immediate
To force immediate binding, link an application with the -B immediate
linker option. For example, to force immediate binding of all symbols in
the main program and in all shared libraries linked with it, you could
use this ld command:
$ ld -B immediate /opt/langtools/lib/crt0.o prog.o -lc -lm