Please don't be afraid of the long post. I think, it does not take more than 30 minutes to read the very detailed instructions and setup the configuration correct for Micro Focus compiler.
Okay, thanks for the details on your UEStudio, Micro Focus compiler and your project.
I setup the same environment as you by doing following:
- I created a directory C:\workarea\cobol32\coboltest.
- I copied C:\Program Files (x86)\IDM Computer Solutions\UEStudio\changes_ues.txt to directory C:\workarea\cobol32\coboltest and renamed this file to source.cbl. That is of course no valid COBOL source code file, but that does not matter.
- I created a directory C:\cobol32\exedll.
- I copied a small executable with file name cobol.exe into the directory C:\cobol32\exedll. Next I copied the same executable once again into same directory with file name cbllink.exe. The executable was written by myself in C and compiled with Visual C 6.0 to a Windows console application. It just outputs to standard output all argument strings passed to the executable.
- I started 32-bit UEStudio v20.10.0.58 and set as user interface mode toolbar/menu mode with contemporary menus.
- I clicked in menu Build in submenu Set Compiler Options on item Set compiler paths, clicked on button ... right to COBOL Compiler, browsed to the folder C:\cobol32\exedll, clicked on button OK and closed the Compiler Paths window with button Close.
- I clicked in menu Project in submenu New project on item New project.
(New project using templates would be also possible because there is in C:\Program Files (x86)\IDM Computer Solutions\UEStudio\projects\COBOL Compiler a file with name User Defined Template.wiz, but that does not seem to be useful on using a different COBOL compiler.
- I browsed to directory C:\workarea\cobol32\coboltest, entered as file name coboltest and clicked on button Save.
- I clicked on button Add file... and added the file source.cbl and opened this file with a double click on it in the tree.
- I selected second tab Settings, clicked on button Set/change compiler, clicked on button COBOL Compiler and selected Application as the compiler configuration to use.
The next steps must be done also by you to get the
Application configuration of
COBOL Compiler working for Micro Focus compiler.
- In the Select Compiler window click on button Edit configuration and next on button Make configuration local (save in project directory).
- Scroll down on right side to section [Variables]. There should be as first variable defined CPATH (short for compiler path) with the path C:\cobol32\exedll. If the default path C:\COBOL is displayed because of having used Set compiler paths after having created the local configuration, just click on button Make configuration local (save in project directory) and UEStudio deletes the local configuration and then press once again on button Make configuration local (save in project directory) to create the local compiler configuration new. This action results in creating a subdirectory Configs in the project directory C:\workarea\cobol32\coboltest with the subdirectory COBOL Compiler and the file Application which is a copy of C:\Program Files (x86)\IDM Computer Solutions\UEStudio\configs\COBOL Compiler\Application.
- Next look on next section [Environment] which defines first the environment variable PATH for the compile/build/rebuild process. The part ;$(CPATH)\BIN can be most likely deleted as there is no directory C:\cobol32\exedll\BIN.
- In section [Environment] are also defined the environment variables INCLUDE and LIB. These two environment variables are very common for compilers.
The environment variable INCLUDE holds the path to the directory containing the header files installed with the compiler. For a C/C++ compiler this directory contains usually the *.h files like stdio.h or string.h included in C/C++ source code files with the instruction #include <stdio.h>. I don't know if COBOL is a programming language supporting also standard header files to include. If the answer is yes, make sure the environment variable INCLUDE is correct defined here. A path starting with $(CPATH) and relative path components is also possible, like $(CPATH)\..\include.
The environment variable LIB holds the path to the directory containing the library files installed with the compiler. For a C/C++ compiler this directory contains usually the *.dll and *.lib files. I don't know if COBOL is a programming language supporting also standard library files to use during linking the object file(s) to an executable or dynamic library. If the answer is yes, make sure the environment variable LIB is correct defined here. A path starting with $(CPATH) and relative path components is also possible, like $(CPATH)\..\lib.
Note: If there is among C:\cobol32\exedll also C:\cobol32\include and C:\cobol32\lib, it would be better to select in Compiler Paths window the path C:\cobol32 and define in local configuration of the compiler in section [Environment] the environment variable PATH with $(CPATH)\exedll;%PATH% to be able to use for the environment variable INCLUDE the value $(CPATH)\include and for the environment variable LIB the value $(CPATH)\lib.
- Click on button Save configuration on having something edited in the configuration and next on button OK to close the Select Compiler window.
- In my case I was back in the Project Settings window on second tab Settings where I selected for Build mode the option Release.
- I closed the Project Settings dialog window with a click on X symbol.
I wanted to test now if clicking in menu
Build on item
Compile results in running
C:\workarea\cobol32\coboltest\cobol.exe for active file
C:\workarea\cobol32\coboltest\source.cbl. Yes, this worked. My program output the following text which was captured by UEStudio and written to the output window:
Code: Select all
Argument 0: COBOL
Argument 1: ..\..\COBOLT~1\source.cbl,source.obj,
I suggest to click in menu
Layout in submenu
Toolbars on item
Build to get the
Build toolbar displayed. Click on last item
Commands of this toolbar and click in popup menu on last item
Show makefile. That results in opening the file
C:\workarea\cobol32\coboltest\Release\coboltest.mak which is the make file created by UEStudio for the compilation of file
source.cbl.
UEStudio sets the selected
Build mode directory always as current directory on running make with the make file in this directory. The project files are referenced by default with using a path relative to project directory if that is possible. This behavior can be changed in the compiler configuration file to use always full qualified path instead of a relative path. In this case is also defined in the compiler configuration to use the short 8.3 file names as it looks like the COBOL compiler for which this configuration was written by a UEStudio user in the past is a 16-bit application not supporting long file names.
Next I clicked in
Build toolbar on fourth item
Build. It is also possible to click in menu
Build on menu item
Build.
There is again output by my
cobol.exe the two lines, but next was captured by UEStudio the error message:
Code: Select all
'COB' is not recognized as an internal or external command,
operable program or batch file.
In other words the linking process step failed because of not finding the executable doing the linking.
So I clicked on toolbar
Build on first item
Project settings, selected tab
Settings and clicked once again on
Set/change compiler. The window
Select Compiler is opened again displaying on right side the local configuration. I explain a bit more now the other sections.
The section
[General] defines some general settings evaluated by UEStudio. The variable
TargetExt is responsible for the definition of the file extension appended to project name to define the target file created on doing a
Build or
Rebuild. For applications is defined usually
.EXE or
.exe and for dynamic libraries
.DLL or
.dll.
ReleaseOut and
DebugOut define the directory names for the output directory created by UEStudio in the project directory on having selected as
Build mode either
Release or
Debug. I think the variables
UseFullPaths and
UseDosNames are self-explaining and are the reason why the COBOL compiler configuration results in creating the make file by UEStudio with using file paths relative to release/debug output directory using short 8.3 names.
We have used already the last line
makef in section
[MakeCommands] by clicking in toolbar
Build on the last item
Commands. In this section are defined special commands to show in the popup menu. The value assigned to a command is the name of a section below like
[Show Makefile]. The command section
[Show Makefile] defines the
Title as shown in popup menu, which command(s) to execute and some additional options used to define the execution environment. Please refer to help of UEStudio if you are interested in the options which can be defined for such a section and what are their meanings.
Important for us is the last section
[.CBL] which defines what should be done on compilation of a project file with the file extension .cbl. It defines first that the output file created during compilation should have the name of the source file with file extension .obj instead of .cbl. There would be two variables to define one or more flags (options) for the used compiler for the
Build mode Debug and
Release. There is nothing defined for the COBOL compiler.
Cmd0 defines the (first) command line to execute on compilation of a .cbl source file. In our case
cobol.exe is executed with the project file as first argument separated by a comma from output file name as defined by above.
$R is briefly explained at top of the compiler configuration with
release/debug setting for linker which is not really a good description. In real
$R references the string assigned to
DebugFlag or
ReleaseFlag according to
Build mode currently set for the project. There are usually some options different for compilation with debugging options (no or just a little optimization, include symbols for debugging) and for release compilation (full optimization, no symbols for debugging).
In the file
coboltest.mak still opened in UEStudio it can be seen in section
COMPILE how the definitions of compiler section
[.CBL] produce for
source.cbl the make instructions to produce
source.obj by running the command line:
Code: Select all
COBOL ..\..\COBOLT~1\source.cbl,source.obj,
However, the main problem is the linking. For the linking the compiler section
[Build] must be correct defined in the compiler configuration. We can see here that the output of the linking process should be the target file as defined by default with project name with
TargetExt value appended as file extension. The linking process depends on the file group
FGO (short for file group output, could be any name) as defined in section
[FileGroups]. In other words
mymake.exe in program files folder of UEStudio executed by UEStudio after creation of the make file in the output directory according to currently selected
Build mode must first make sure that for each *.cbl file of the project the *.obj file is created using the COBOL compiler command line as defined by section
[.CBL].
mymake.exe runs the compiler
cobol.exe for a *.cbl file only if the source file is newer than the *.obj file. The command
Rebuild results in first running
CLEAN as defined in the make file to delete the target file and all the object files and than do a
Build with a
Compile for each *.cbl file before running the linker as defined with
Cmd0 in section
[Build].
COB is definitely wrong for Micro Focus compiler as the executable has the file name
cbllink.exe. So
COB must be modified to
cbllink or
cbllink.exe. (The definition of the executable with file extension is a very little bit faster.) Click on the buttons
Save configuration and
OK and on
X symbol of window
Project Settings after this modification.
Next click in menu
Build on
Regenerate makefile if UEStudio has not automatically created the make file new after making this modification in compiler configuration. It can be seen now in the make file in section
BUILD that the target file for linking
coboltest.EXE is created with execution of:
Code: Select all
cbllink.exe -X:LRS -Ocoboltest.EXE $(FG00)
$(FG00) (file group outputs 0) is the list of *.obj files according to *.cbl files of the project.
In my case I get output into the output window on running a
Build with my program being
cbllink.exe:
Code: Select all
Argument 0: cbllink.exe
Argument 1: -X:LRS
Argument 2: -Ocoboltest.EXE
Argument 3: source.obj
So I was finished with the configuration. But I suppose the linking options are not really right for you as
cbllink.exe requires most likely different options than not existing
COB.exe. So we have to do more.
Now it is essential to know which options the compiler executable
cobol.exe and the linker executable
cbllink.exe offer and which one to use for the current project. In the compiler configuration are the sections
- [Settings] ... defines the possible values for the compiler/linker options.
- [SettingsInfo] ... defines the information shown the user for each compiler/linker option defined in [Settings].
- [SettingsReps] ... defines the compiler/linker options used on running the compiler/linker executable depending on the values selected or entered for each setting.
The string values assigned to the variables as defined in section
[SettingsReps] are used in the section
[Variables] to form the a string with several options assigned to variable
COPT for compilation and
LOPT for linking (last step in build process).
The variables defined in section
[Variables] can be used now in section
[.CBL] on the lines which define
DebugFlag and/or
ReleaseFlag or directly on
Cmd0 command line to execute for compilation of a *.cbl file as well as in section
[Build] on
Cmd0.
So let us open now the
Project settings and click on second tab
Settings on button
Compiler options showing a dialog window to configure the compiler and linker options as defined in the section
[Settings], evaluated according to
[SettingsReps] forming the string for the variables defined in
[Variables] and used on running
Cmd0 as defined in section
[.CBL] for compilation of each *.cbl project file and
Cmd0 as defined in section
[Build] to link all the object files together to target executable file.
The first option is
Target to redefine the target file name referenced with
$T in the compiler configuration which is defined by default with project name and value of variable
TargetExt appended. This first option gives the user the possibility to define a different executable file name independent on the defaults. It is up to you what you want to enter here.
The two options below
DEFAULT RUN CONFIGURATION are only of interest if you ever click in toolbar
Build on last item
Commands and click next on first item
Execute coboltest.EXE. Then UEStudio runs
mymake.exe with option
run to run the executable as defined in the make file in section
COMMANDS created according to compiler configuration in section
[Execute Application].
The section
COMPILER OPTIONS contains only the setting
Compiler Options. So the creator of the COBOL configuration file has defined in section
[Settings] no option for compilation of a *.cbl file at all. The user has to enter here the options to use on running the compiler executable. So you have to study the manual of
cobol.exe to define the string which is appended at end of the command line running
cobol.exe.
The section
LINKER OPTIONS contains
Linker Options where a user can enter all the options to use on linking which is in your case the executable
cbllink.exe. So I recommend to enter here the linker options needed to link the object files. But the creator of COBOL compiler configuration decided to offer some of the linker options to be configured more easily directly and processing them according to the sections
[SettingsReps] and
[Variables] for usage on
Cmd0 in section
[Build]. I cannot tell you if these settings can be used at all or if you better rewrite these sections to get finally the needed linker command line.
You can of course modify
Cmd0 in section
[Build] from
Code: Select all
cbllink.exe $(LOPT) -O$O $FGO $FGL
to
Code: Select all
cbllink.exe WHATEVER LINKER OPTIONS NEEDED -O$O $FGO $FGL
Then ALL the options in the section
LINKER OPTIONS in the
Compiler Options are ignored on linking as none of them are referenced in the command line written into the make file for linking the object files of the project source files to an executable file.
I hope this helps you to get the COBOL compiler configuration correct adapted for Micro Focus compiler for at least building or COBOL project to an executable running fine. Let me know if you want to know more.
PS: Click in menu
Build on
Options and check
Show build commands when executing. Then you can see in output window also the command lines used by
mymake.exe to compile the *.cbl file(s) with
cobol.exe and link the object file(s) with
cbllink.exe to the executable file as defined in the compiler options window.