COBOL Manual for TNS and TNS/R Programs

Libraries and Utility Routines
HP COBOL Manual for TNS and TNS/R Programs522555-006
13-22
Specifying a DLL
PC Environment: Compile and Link in Two Steps
1. Compile the program that uses the DLL with these options:
-Wcall_shared
-c
-Wcobol, with the argument “CONSULT MYDLL”
The result is a linkfile.
2. Link the linkfile, using the ld utility with these ld options:
-l or -lib (which is similar to the nmcobol option -l), where library is
the name of the DLL
-optional_lib followed by:
°
-L lib-directory -lcob, which links your file with the SRL named
ZCOBSRL
°
-obey lib-directory\libc.obey, which links your file with the SRL
named ZCRESRL
lib-directory is the name of the directory of libraries.
For more information about the ld options -l or -lib, see the ld Manual.
In Example 13-15, the first command compiles the source file main.cob, specifying
the DLL named MYDLL and creating the linkable object file main.o. The second
command links main.o with mydll and the SRLs named ZCOBSRL and ZCRESRL,
creating the loadfile main.exe. MYDLL is in dll-location. (An example of dll-
location is C:\xxx\yyy.)
Example 13-15. Specifying a DLL When You Compile and Then Link (PC)
nmcobol main.cob -Wcall_shared -c -Wcobol="CONSULT MYDLL"
ld main.o -call_shared
-L dll-location -l mydll -optional_lib
-L lib-directory -lcob -obey lib-directory\libc.obey -o main.exe