DLL Programmer's Guide for TNS/E Systems
DLL Programmer’s Guide for TNS/E Systems—527252-006
3-1
3 Dynamic Use of DLLs
An important attribute of the DLL facility is that a running PIC program or DLL can load
and open a previously not-loaded DLL and gain access to the symbols it offers. DLLs
invoked this way are called dynamically loaded DLLs.
One advantage of dynamically loading a DLL is that its name need not be known when
the program is constructed; instead, you can add this new DLL to an existing
application without even restarting the application. Also, you do not need to load
infrequently used DLLs when the application is loaded. Instead, you can load and use
these DLLs when needed and unload them when they are no longer required. They
can be reloaded whenever necessary.
Dynamic libraries make it possible to update facilities in a running application. If
specific business functions are implemented in a dynamically loaded DLL, a program
can unload that DLL and load an updated version that supports the same interfaces
with revised algorithms, tables, etc.
This section discusses how to dynamically load and unload a DLL from your running
process and how to link your loadfile with a dynamically loaded DLL.
rld is the facility that loads a program and its requisite libraries. It will load a preset
loadfile without rebinding ordinary symbols if the loadfile bindings are correct. This is
called FastLoad. A FastLoadable loadfile is one whose bindings have been preset by
eld, or automatically updated by rld and the NonStop operating system.
If rld has to rebind a loadfile and the loadfile import control is localized, it will update
the preset bindings in the loadfile with the cooperation of the NonStop operating
system. This is called automatic update. rld and the operating system only
automatically update loadfiles at process creation time. If a loadfile is loaded via a call
to dlopen(), the loadfile is not automatically updated.
Reference information about dynamic linking may be found in the rld Manual.
For the C/C++ languages, declarations for the runtime dynamic linking functions and
the dlopen() mode options are provided in a header file called dlfcnh on the
Guardian platform and dlfcn.h on the OSS/Unix/PC platforms. For the pTAL
language, a header file called hdlfcn is provided on the Guardian plat
form containing
the same declarations.
The rest of this section details the loading facilities based on C/C++ language
functions.
Dynamic Loading Functions
Dynamic loading and linking use five associated C-language functions, dlopen(),
dlsym(), dlclose(), dlerror( ) and dlresultcode(). These functions
compose the dynamic library function calls described in this section, and they are










