COBOL Manual for TNS and TNS/R Programs

Libraries and Utility Routines
HP COBOL Manual for TNS and TNS/R Programs522555-006
13-17
Building a DLL from Multiple Source Files
OSS Environment
1. Compile each source file with these options:
-Wshared
-c
The result of each compilation is a linkfile.
2. Link the linkfiles into a single loadfile, using the ld utility with these options:
Either:
°
-export_all, which exports all program names in the source file
°
-export program-name, which exports only the specified program
name. You must repeat this option for every program name that you want
to export.
-shared, which links the linkfiles into a single loadfile that is a DLL
-optional_lib -l ZCOBSRL -l ZCRESRL, which links your file with the
SRLs named ZCOBSRL and ZCRESRL
In Example 13-8, the first four commands compile four source files (lib1.cob,
lib2.cob, lib3.cob, and lib4.cob), creating four linkable object files (lib1.o,
lib2.o, lib3.o, and lib4.o). The last command links the four linkable object files
with the SRLs named ZCOBSRL and ZCRESRL, creating a DLL named mydll.
PC Environment
1. Compile each source file with these options:
-Wshared
-c
The result of each compilation is a linkfile.
Example 13-8. Building a DLL From Multiple Source Files (OSS)
nmcobol lib1.cob -Wshared -c
nmcobol lib2.cob -Wshared -c
nmcobol lib3.cob -Wshared -c
nmcobol lib4.cob -Wshared -c
ld lib1.o lib2.o lib3.o lib4.o -shared -export_all -optional_lib
-l ZCOBSRL -l ZCRESRL -o mydll