Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
User Commands (m - o) nmcobol(1)
If you want the libraries to be searched in a specific order or you want linking options to be pro-
cessed in a specific order, you should invoke the linker using the ld or nld command from the OSS
shell and not use nmcobol to do the linking.
Differences Between Static and Dynamic Linking
The -WBdllsonly and -WBdynamic operands specify dynamic linking. The -WBstatic operand
specifies static linking.
In dynamic linking, the nld utility first searches for a shared run-time library (SRL) or the ld utility
first searches for a dynamic-link library (DLL). If an SRL or DLL cannot be found, the linker util-
ity searches for an archive file. If no archive file can be found, an error is issued.
In static linking, the linker utility searches for an archive file but does not search for an SRL or
DLL. If the archive file cannot be found, an error is issued.
Dynamic and static linking are not exact opposites. Dynamic linking accepts either an SRL, DLL,
or an archive file, but static linking accepts only an archive file.
Unlike nmcobol flags, multiple -WBdllsonly, -WBdynamic, and -WBstatic operands can be
specified in a single nmcobol invocation; thus, it is possible to perform dynamic linking for some
-l operands and static linking for others.
-WBdllsonly, -WBdynamic and -WBstatic operands specified to nmcobol are temporarily over-
ridden by linking arguments specified in the -Wld, -Wnld, -Wld_obey,or-Wnld_obey flags.
The nld utility performs dynamic linking by default. The ld utility can be used instead. Refer to
the ld(1) or nld(1) reference page for more information.
Using the c89 and nmcobol Utilities
OSS COBOL85 programs can contain COBOL85 modules and C modules. Compile COBOL85
modules using the nmcobol utility and C modules using the c89 utility. To produce a program
containing COBOL85 and C modules, first compile all the modules written in either COBOL85 or
C. You can also link these modules together or with other libraries at this time, but do not SQL-
compile the modules. After you have compiled all the modules of one language, compile the
modules written in the other language, specifying any necessary linking or SQL-compiling
options.
For example, to produce an executable object file made up of COBOL85 modules cobol1.cbl and
cobol2.cbl and C modules c1.c and c2.c, you can first run the C compiler using the c89 utility
with:
c89 -c -o cprog.o c1.c c2.c
This command directs c89 to compile the two modules but not link them. The output object file is
cprog.o.
You can then invoke the nmcobol utility to compile the two COBOL85 modules and link the
NMCOBOL compiler output with the previously produced C object file and the standard C library
to produce the executable object myprog with:
nmcobol -o myprog cprog.o cobol1.cbl cobol2.cbl
Refer to the C/C++ Programmer’s Guide and the Open System Services Programmer’s Guide for
details on writing and compiling C programs in the OSS environment.
EXAMPLES
1. The command
nmcobol test1.cbl
compiles the source file test1.cbl and links the object file into a program file a.out.
527188-003 Hewlett-Packard Company 6−67