Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)
and c99 Files” (page 42); file locations are different between the native and TNS C compilation
tools.
For more information about compiling and linking files with c89 or c99, refer to the c89(1) or
c99(1) online reference page or the Open System Services Shell and Utilities Reference Manual.
Refer also to the C/C++ Programmer’s Guide.
Using nld to Link Native Object Files
The nld utility collects, links, and modifies code and data blocks from one or more TNS/R native
object files to produce a non-PIC executable native object file. nld can be used in the OSS and
Guardian environments.
When using native c89 to compile code, c89 invokes nld automatically for you. If no c89 flags
that prevent linking (such as -c or -E) are given, and all source files compile without error, nld
links the native object files with any libraries specified on the command line, and an executable
object file is written to an output file.
To run nld from the Guardian environment, you need to type nld at the system prompt. The nld
Manual describes how to invoke and use the nld utility.
NOTE: You cannot use nld or noft on TNS interpreted or accelerated object files.
Using ld or eld to Link Native Linkfiles
If you If you intend to create dynamic-link libraries (DLLs) or create a program that uses DLLs, you
must use the ld or eld linker to create a file consisting of position-independent code (PIC). ld is
the TNS/R native PIC linker; it runs on G-series, H-series, and J-series RVUs, but its output can be
executed only on G-series systems. eld is the TNS/E native PIC linker, and runs on H-series and
J-series systems. The ld and eld linkers combine compiler-generated PIC linkfiles and create
necessary tables and structures to produce a PIC loadfile. The loadfile is either a program or a
DLL. Loadfiles created by ld or eld are loaded into virtual memory for execution by the rldloader,
which works with the operating system. ld, eld, and rld can be used in the OSS and Guardian
environments.
To create a PIC linkfile when using the c89 or c99 utility, specify either the -Wcall_shared
option (creates a PIC linkable object file) or the -Wshared option (creates PIC code and invokes
either ld or eld to create a DLL, depending on whether the program is being compiled for the
TNS/R or the TNS/E platform). ld or eld links the linkfile with any other linkfiles specified on the
command line, and writes a loadfile to a specified output file. You can also specify DLLs to be
loaded with the current loadfile.
To run ld or eld from the Guardian environment, type ld or eld at the system prompt. The ld
Manual, eld Manual, and rld Manual describe how to invoke and use the ld, eld, and rld
utilities.
NOTE: You cannot use ld or eld on TNS interpreted or accelerated object files.
Using Binder for TNS Object Files
By default, the G-series c89 utility for TNS object files performs dynamic binding. In dynamic
binding, the Binder resolves references to library functions using a shared run-time library (SRL).
Final resolution of references is performed at run time. Programs that use an SRL cannot use a user
library. Dynamic binding produces smaller program files and uses fewer system resources than
static binding. Static binding is also available with the G-series TNS c89 utility.
You can perform static binding for OSS programs. In static binding, the Binder resolves references
to library functions by binding the functions into the program. Static libraries can be used for
dynamic binding. The Binder resolves external references using all the specified static libraries
before using the SRL. An SRL is an object file that the operating system links to program files at run
time.
Working on the NonStop System 41