COBOL Manual for TNS and TNS/R Programs
Libraries and Utility Routines
HP COBOL Manual for TNS and TNS/R Programs—522555-006
13-21
Specifying a DLL
2. Link the linkfile, using the ld utility with these ld options:
•
-L (which is similar to the nmcobol option -L)
•
-l or -lib (which is similar to the nmcobol option -l)
•
-optional_lib -l ZCOBSRL -l ZCRESRL, which links your file with the
SRLs named ZCOBSRL and ZCRESRL
For more information about the ld options -l or -lib, see the ld Manual.
In Example 13-13, 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.
PC Environment: Compile and Link in One Step
Compile the program that uses the DLL with these nmcobol flags:
•
-Wcall_shared
•
-Wcobol with the argument “CONSULT MYDLL”
•
-L, where directory is the name of the directory of libraries
•
-l, where library is the name of the DLL
The result is a loadfile.
The command in Example 13-14 compiles the source file main.cob and links the
resulting object file with the SRLs named ZCOBSRL and ZCRESRL and the DLL
named mydll, creating the loadfile main.exe. MYDLL is in dll-location. (An
example of dll-location is C:\xxx\yyy.)
Example 13-13. Specifying a DLL When You Compile and Then Link (OSS)
nmcobol main.cob -Wcall_shared -Wcobol="CONSULT MYDLL" -c
ld main.o -call_shared -L /usr/xxx/yyy -l mydll -optional_lib
-l ZCOBSRL -l ZCRESRL -o main.exe
Note. Do not use -c.
Example 13-14. Specifying a DLL When the Compiler Calls the Linker (PC)
nmcobol main.cob -Wcall_shared -Wcobol="CONSULT MYDLL" -L dll-location
-l mydll
-optional_lib -L lib-directory -l ZCOBSRL -l ZCRESRL
-o main.exe