SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
COBOL Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
16-38
Combining Embedded Module Definitions and
Module Definition Files
The file sqlprog.cbl is the COBOL annotated source file, and the file 
sqlprog.m is the corresponding module definition file. The nmcobol utility then 
compiles and links sqlprog.cbl to produce the executable file, sqlprog.exe. 
The SQL/MX compiler command -Wmxcmp processes the module definition file 
sqlprog.m with the SQL/MX compiler, mxcmp, to produce the module.
•
These commands preprocess several COBOL source files and compile them, but 
they do not link the results: 
nmcobol -c -Wsqlmx -Wsqlmxadd=-x sqlprog1.ecob \
sqlprog2.ecob sqlprog3.ecob
If no errors are detected in either the preprocessing or compiling steps, these files 
are created: sqlprog1.m, sqlprog2.m, sqlprog3.m, sqlprog1.cob, 
sqlprog2.cob, sqlprog3.cob, sqlprog1.o, sqlprog2.o, and 
sqlprog3.o.
•
These commands preprocess and compile COBOL source files with and without 
embedded SQL without linking:
nmcobol -c -Wsqlmx -Wsqlmxadd=-x file1.cbl file2.ecbl \
file3.ecob file4.cob
If no errors are detected in either the preprocessing or compiling steps, these files 
are created: file2.m, file2.cbl, file3.m, file3.cob, file1.o, file2.o, 
file3.o, file4.o.
•
If you did not link your object files by using the nmcobol utility, create the 
executable program by using the nld utility to link one or more object files. For 
example, these commands link sqlprog1.o, sqlprog2.o, and find the required 
CLI procedure definitions to create an executable file named sqlprog.exe:
nld -lzcobsrl -lzcresrl -lzclisrl sqlprog1.o sqlprog2.o \
-o sqlprog.exe
For more information on nld, see the nld Manual.
Combining Embedded Module Definitions and 
Module Definition Files 
Suppose that you have a set of SQL COBOL utility routines that were developed with 
module definition files. The object code is in sqlutil.o. To build, statically link in 
sqlutil.o, and deploy a new application sqlapp.exe on OSS:
1. Create the COBOL source file (for example, sqlapp.ecbl) that contains 
embedded SQL/MX statements:
* sqlapp.ecbl 
?CONSULT sqlutil.o
 IDENTIFICATION DIVISION.
 PROGRAM-ID. sqlapp. 
 DATA DIVISION. 










