Problem:
Cbllink executes three other programs: the Cobol Compiler; Cblnames; and Link. The parameter input to Cbllink, consisting of switches and filenames, determines the programs executed, the output files created, the output files retained and the Run time the program produced will utilize.
The "Usage" for this program is documented as follows:
usage:
cbllink [-V] [-S] [-D] [-G] [-L] [-K] [-Boptions] [-Foption] [-Roption
[-Mname] [-Oname] file1 [file2,...]
This can be simplified, and adjusted to improve the accuracy, as follows:
usage: cbllink [switches] fileName1[.extension] [fileName2[.extension] ...]
The switches you specify are actually a combination of Cbllink and Cblnames switches. The switch possibilities are covered in Cbllink & Cblnames Switches. The filename and file extension possibilities are covered in Cbllink File Types.
Resolution:
Cbllink & Cblnames Switches
The following lists the Cbllink and Cblnames switches. The -S switch is common to both programs, however, the switch function is different. The -K and -L switches are unique to Cbllink. The remaining switches are common to and consistent for both programs.
Cbllink
Cblnames
-S Exclude System programs
-S Include System programs and
Create a Link Response file
Specify the "-S" switch to Cbllink and this switch is omitted from the Cblnames command line. Cblnames will not create a Link response file (cbllds.lnk), but it will create a cbllds.obj file. The Link command line composed will include the object files for the programs compiled and the cbllds.obj file.
Omit the "-S" switch for Cbllink and the Cblnames command line will includes the "-S" switch. A Link response file (cbllds.lnk) will be created and will include the object files for all the programs processed as well as the system modules needed. A cbllds.obj file will also be created.
When creating an all Cobol application consisting of an Exe and one or several Dll files, don't use the "-S" switch when processing the programs being linked into the Exe. This will ensure that the system modules are linked into the Exe. When creating the Dlls, use the "-S" switch to keep the system modules already linked into the Exe out of the Dlls.
Some experimentation may be necessary to determine exactly what system modules are required by the Dllls. It is possible that a Dll may require a system module that none of the programs being linked into the Exe program require. In this situation compile the programs for the Exe with Cobol and create a response file for Cblnames consisting of all the programs needed to create the Exe, including the system modules needed by the Exe and the additional system modules needed by the Dlls. Submit the Cblnames response file to Cbllink, prefixed by an "@" sign to create the Exe.
This same situation can occur when the Exe program is not a Cobol program. Make one of the Cobol Dlls a primary or "Bridge" Dll. Ensure that the Exe program calls this Dll before calling any other Cobol Dll. This will make the system modules linked into the primary Dll available to all the other Cobol Dlls.
Cbllink
Cblnames
-K Keep files
link response file (.lnk)
module definition file (.def)
export symbols file (.exp)
symbols object file (cbllds.obj)
import library file (.lib)
The "-K switch is most useful when you are creating a DLL that you will be calling from another Executable, be it a DLL, an EXE or a program written in another language. The import library is normally discarded by Cbllink. You may consider retaining these files all the time as they do capture a lot of information about the program just created. Be cautious about reusing these files, they would need to be synchronous with the current release.
Cbllink
Cblnames
-L Create Link MAP file
The "-L" switch causes the Link program to create a Map file. Like the files retained by the "-K" switch this file also contains a lot, and I mean a lot, of information about the executable just created. This file should also be retained syncronous with the current release of the program.
Cbllink
Cblnames
-V Verbose
-V Verbose
The "-V" switch causes a detailed display to the screen of the command lines that execute the programs run by Cbllink, and the results for each program. The amount of information produced can easily become several full screens of information. Redirect this output to a text file to capture a comprehensive record of Cbllink processing.
Cbllink
Cblnames
-D Dynamic link library name
-D Dynamic link library name
Use the "-D" switch when you need to create a DLL. The default is to create an EXE. Note that the "-K" switch can be used to retain the import library for the DLL.
Cbllink
Cblnames
-G Graphical
-G Graphical
Use the "-G" switch when the program being created manipulates a graphical Window. The default is to create a Console application. Both Graphical and Console applications will make use of Win32 Api calls.
Cbllink
Cblnames
-M Main entry point name
-M Main entry point name
When you use Cbllink to process multiple programs, use the "-M" switch to identify the entry name that should be used when the program is started. This name can be either a source file name or a Cobol Program-Id name.
Cbllink
Cblnames
-O Output file name
-O Output file name
Use the "-O" switch to assign a name to your output file. The deafult name is the same as the file name of the program containing the main entry point name.
Cbllink
Cblnames
-B![]()
Static runtime
-B![]()
Static runtime
S single thread
S single thread
M multi thread
M multi thread
L for Lite
L for Lite
B for Base
B for Base
F for Full
F for Full
D debugging support
D debugging support
-F Shared runtime
-F Shared runtime
S single thread
S single thread
M multi thread
M multi thread
-R Dynamic Shared runtime
-R Dynamic Shared runtime
S single thread
S single thread
M multi thread
M multi thread
E single/multi thread
E single/multi thread
V bind to this version only
V bind to this version only
The "-B," "-F" and "-R" switches determine which Run time your program will use.
Use the "-B" switch to create a Static linked application that will execute independent of Run time support files.
Use the "-F" switch to create a Shared Run time application that requires Run time support files.
The "-R" switch also creates a Shared Run time application, however, the application can be bound to the Run time you are using to create the application. This means that the application will not execute with any other version of the NetExpress Run time. Use of this feature is optional.
In addition, "-R" switch also provides an option that will permit the application running with either the single thread Run time or the multi thread Run time. Whichever Run time is installed will be acceptable.
Be cautious when using the "-S" switch and selecting the Run time for your application. The "-S" switch causes system object modules to be omitted from your programs. If your objective is the Static Run time, you will need to link the objects you are omitting into a separate Dll. It may be simpler to link these modules into your program by not using the "-S" switch.
When the Shared Run time is your objective, using the "-S" to keep the system modules out of your programs is a reasonable consideration. The File Handler, as an example, already exists as a separate Dll.
Cbllink File Types
Cbllink will execute, depending upon the filenames specified, up to three other programs: the Cobol Compiler (optional); Cblnames; and Link. The Compiler step is only executed when a file with either .CBL, .COB or .INT extension is specified. Listed below are the various file "types" that can be submitted to Cbllink and their corresponding file extensions.
Cobol source program files
.CBL or .COB extension
Micro Focus Intermediate code files
.INT extension
Object code files
.OBJ or no extension
Cblnames Response file
file name prefixed by "@"
Import Library files
.LIB extension
Graphical Resource files
.RES extension
When you specify a filename without an extension Cbllink assumes the file is an object file, skips the compile step and immediately starts Cblnames. The same will occur when you specify the OBJ extension. You can submit a mixture of .CBL, .INT and .OBJ files. The CBL files will be compiled, the INT files will be generated as OBJ files, and all the OBJ files will be passed on to Cblnames. If all you have to work with are OBJ files, and there are so many files that they cannot all be enterred on the command line, prepare a text file listing the object files and submit it as a Cblnames response file to Cbllink (ie. Cbllink @Cblnames.rsp).
Example #1
MyPgm.cbl
123456$ set Ans85 Mf NoOsvs NoVsc2 NoQual NoAlter DefaultByte"00"
special-names.
call-convention 8 is static.
working-storage section.
78 programName value 'MyPgm'.
78 entryName value 'MyEntry'.
1 MyEntryPtr procedure-pointer.
local-storage section.
procedure division.
display programName at 1010
set MyEntryPtr to entry 'MyEntry'
call static 'MySub' using by value MyEntryPtr
exit program
stop run.
entry 'MyEntry'.
display entryName at 1310
exit program
stop run.
MySub.cbl
123456$ set Ans85 Mf NoOsvs NoVsc2 NoQual NoAlter DefaultByte"00"
special-names.
call-convention 8 is static.
working-storage section.
78 programName value 'MySub'.
linkage section.
1 MyEntryPtr procedure-pointer.
procedure division using by value MyEntryPtr.
display programName at 1110
call static 'MySub2' using by value MyEntryPtr
exit program
stop run.
MySub2.cbl
123456$ set Ans85 Mf NoOsvs NoVsc2 NoQual NoAlter DefaultByte"00"
special-names.
call-convention 8 is static.
working-storage section.
78 programName value 'MySub2'.
linkage section.
1 MyEntryPtr procedure-pointer.
procedure division using by value MyEntryPtr.
display programName at 1210
call MyEntryPtr
exit program
stop run.
Doit.bat
@echo off
::Doit.bat
cobol mypgm obj;>ThePgm.txt
cobol mysub nognt;>>ThePgm.txt
cbllink -v -k -mMYPGM -oTHEPGM -BSF mypgm mysub.int mysub2.cbl>>ThePgm.txt
ThePgm.txt
Micro Focus NetExpress V3
Version 3.0.14 Copyright (C) 1984-1998 Micro Focus Ltd.
URN AXCGG/AA0/00000
* Checking complete with no errors - starting code generation
* Generating mypgm
* Data: 264 Code: 608 Literals: 172
Micro Focus NetExpress V3
Version 3.0.14 Copyright (C) 1984-1998 Micro Focus Ltd.
URN AXCGG/AA0/00000
* Checking complete with no errors
Micro Focus NetExpress - CBLLINK utility
Version 3.0.14 Copyright (C) 1984-1998 Micro Focus Ltd.
Executing:cobol mysub.int;
Micro Focus NetExpress V3
Version 3.0.14 Copyright (C) 1984-1998 Micro Focus Ltd.
URN AXCGG/AA0/00000
* Starting code generation
* Generating mysub
* Data: 384 Code: 496 Literals: 156
Executing:cobol mysub2.cbl;
Micro Focus NetExpress V3
Version 3.0.14 Copyright (C) 1984-1998 Micro Focus Ltd.
URN AXCGG/AA0/00000
* Checking complete with no errors - starting code generation
* Generating mysub2
* Data: 384 Code: 520 Literals: 148
Executing:cblnames /N /V /S /BFS /MMYPGM mypgm.obj mysub.obj mysub2.obj
Scanning object files:-
mypgm.obj
found public -> MYPGM
found public -> MYENTRY
mysub.obj
found public -> MYSUB
mysub2.obj
found public -> MYSUB2
acccgi.obj
found public -> ACCCGI
found public -> CBL_ACCEPT_EXTERNAL
found public -> CBL_DISPLAY_EXTERNAL
found public -> CBL_WRITE_BROWSER
adis.obj
found public -> ADIS
adisinit.obj
found public -> ADISINIT
adiskey.obj
found public -> ADISKEY
adisdyna.obj
found public -> ADISDYNA
mffh.obj
found public -> MFFH
found public -> MAPPER
found public -> ESDSFH
found public -> FHREDIR
found public -> XFH_CLOSE_MVS
found public -> XFH_CLOSE_MAPPER
found public -> FHR_CLOSE
bsio.obj
found public -> BSIO
found public -> STRIPE_INITIALIZE
found public -> STRIPE_OPEN_FILE
found public -> STRIPE_CREATE_FILE
found public -> STRIPE_DELETE_FILE
found public -> STRIPE_COPY_FILE
found public -> STRIPE_RENAME_FILE
found public -> STRIPE_CLOSE_FILE
found public -> STRIPE_READ_FILE
found public -> STRIPE_SEEK_END
found public -> STRIPE_WRITE_FILE
found public -> STRIPE_SETSEMA
found public -> STRIPE_RELSEMA
found public -> STRIPE_LOCKFILE
found public -> STRIPE_UNLFILE
found public -> STRIPE_UNLOCK
found public -> STRIPE_TEST_RECORD_LOCK
found public -> STRIPE_GET_RECORD_LOCK
found public -> STRIPE_FREE_RECORD_LOCK
found public -> STRIPE_FLUSH_FILE
found public -> STRIPE_CONFIG_INFO
extfhsub.obj
found public -> EXTFHSUB
found public -> XFH_FUNC
found public -> XFH_INITIALISE
found public -> XFH_CLOSE
mfini.obj
found public -> MFINI
extsm.obj
found public -> EXTSM
found public -> EXTSORT
found public -> XSM_CLOSE_EXTSM
externl.obj
found public -> CHECKFIL
found public -> CHECKKEY
found public -> CHECKKY2
_class.obj
found public -> _CLASS
_codeset.obj
found public -> _CODESET
found public -> CODESET
Creating cbllds.obj
Creating cbllds.lnk
CBLNAMES completed
Executing:link -subsystem:console -base:0x400000 -nodefaultlib @cbllds.lnk -out:THEPGM.exe cblrtss.lib msvcrt.lib kernel32.lib user32.lib gdi32.lib advapi32.lib
Microsoft (R) 32-Bit Incremental Linker Version 5.00.7022
Copyright (C) Microsoft Corp 1992-1997. All rights reserved.
mypgm.obj
mysub.obj
mysub2.obj
acccgi.obj
adis.obj
adisinit.obj
adiskey.obj
adisdyna.obj
mffh.obj
bsio.obj
extfhsub.obj
mfini.obj
extsm.obj
externl.obj
_class.obj
_codeset.obj
cbllds.obj
Creating library THEPGM.lib and object THEPGM.exp
CBLLINK completed