Hi,
Trying to compile a simple Cobol-Db2 program (DB2 ECM - Select) to test the setup as mentioned here: Demonstration Applications (microfocus.com)
Getting these error messages during build:
Build started...
------ Build started: Project: Select, Configuration: Debug x86 ------
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select\\Select.cbl (1,1-2) : error COBDB0006 : Required DB software 'db2agapi' could not be found.SQL processing cannot continue.
* Compiling "C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select\\Select.cbl"
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select\\Select.cbl (74,15-22) : error COBCH0012 : Operand sqlcode is not declared
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select\\Select.cbl (77,25-33) : error COBCH0012 : Operand sqlerrmc is not declared
COBOL compile: 0 item(s) succeeded or up-to-date, 1 failed.
In Link with libs field have added db2api.lib (full path to the file). In fact have Db2 lib: C:\\Program Files\\IBM\\SQLLIB\\lib in Path & Lib environment variable as well.
This is what I have:
DB2 v11.5.4 (Community Edition) on Win 10 Pro.
Micro Focus Visual COBOL 8.0 for Visual Studio 2022
Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.5.4
Thanks.
Gagan
Hi,
Trying to compile a simple Cobol-Db2 program (DB2 ECM - Select) to test the setup as mentioned here: Demonstration Applications (microfocus.com)
Getting these error messages during build:
Build started...
------ Build started: Project: Select, Configuration: Debug x86 ------
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select\\Select.cbl (1,1-2) : error COBDB0006 : Required DB software 'db2agapi' could not be found.SQL processing cannot continue.
* Compiling "C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select\\Select.cbl"
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select\\Select.cbl (74,15-22) : error COBCH0012 : Operand sqlcode is not declared
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select\\Select.cbl (77,25-33) : error COBCH0012 : Operand sqlerrmc is not declared
COBOL compile: 0 item(s) succeeded or up-to-date, 1 failed.
In Link with libs field have added db2api.lib (full path to the file). In fact have Db2 lib: C:\\Program Files\\IBM\\SQLLIB\\lib in Path & Lib environment variable as well.
This is what I have:
DB2 v11.5.4 (Community Edition) on Win 10 Pro.
Micro Focus Visual COBOL 8.0 for Visual Studio 2022
Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.5.4
Thanks.
Gagan
Hi Gagan,
Do you have C:\\Program Files\\IBM\\SQLLIB\\BIN within the PATH?
This is normally where the db2agapi.dll is located.
Hi Gagan,
Do you have C:\\Program Files\\IBM\\SQLLIB\\BIN within the PATH?
This is normally where the db2agapi.dll is located.
Hi Chris,
Yes, that folder is there within the PATH. And db2agapi.dll is in that folder.
Hi Chris,
Yes, that folder is there within the PATH. And db2agapi.dll is in that folder.
it looks like you may be compiling for 32-bit but you have the 64-bit DB2 installed. Try setting the project type to x64 instead of x86...
it looks like you may be compiling for 32-bit but you have the 64-bit DB2 installed. Try setting the project type to x64 instead of x86...
Hi Chris,
Yes, tried that as well. Same issue.
While I have a workaround to compile/link etc. from a command line but would have preferred that working in Visual Studio.
Thanks.
Hi Chris,
Yes, tried that as well. Same issue.
While I have a workaround to compile/link etc. from a command line but would have preferred that working in Visual Studio.
Thanks.
I searched our internal problem tracking system and found the exact error that you are experiencing when trying to compile the DB2 samples using VS2022 and VC 8.0. The resolution was the following:
To build DB2 ECM samples with VS 2022, with Platform=x64, everything will build fine as-is. With Platform=x32, make sure the environment variable %LIB% contains the DB2 32bit library folder first <DB2 Installed Folder>\\sqllib\\lib\\win32.
When you state that this works from the command line are you referring to a Visual COBOL Command Prompt (32-bit or 64-bit) or just a standard system command prompt? I believe that when compiling for x64 it should also look for db2agapi64.dll. Is this file present?
I will try to install DB2 on my system today and test this but I think that as long as things are pointing to the correct bitism all should work.
I searched our internal problem tracking system and found the exact error that you are experiencing when trying to compile the DB2 samples using VS2022 and VC 8.0. The resolution was the following:
To build DB2 ECM samples with VS 2022, with Platform=x64, everything will build fine as-is. With Platform=x32, make sure the environment variable %LIB% contains the DB2 32bit library folder first <DB2 Installed Folder>\\sqllib\\lib\\win32.
When you state that this works from the command line are you referring to a Visual COBOL Command Prompt (32-bit or 64-bit) or just a standard system command prompt? I believe that when compiling for x64 it should also look for db2agapi64.dll. Is this file present?
I will try to install DB2 on my system today and test this but I think that as long as things are pointing to the correct bitism all should work.
I installed the latest DB2 Community Editon 64-bit and tested the sample 'select' and it worked fine. All I did was open up the configuration manager and change the platform to a new x64 platform and then it built and ran fine within the IDE.
I installed the latest DB2 Community Editon 64-bit and tested the sample 'select' and it worked fine. All I did was open up the configuration manager and change the platform to a new x64 platform and then it built and ran fine within the IDE.
Hi Chris,
This is what I have. Please can you share your configuration details. Thanks.
..
Hi Chris,
This is what I have. Please can you share your configuration details. Thanks.
..
Mine looks the same as yours on the COBOL tab. The only property I changed was the configuration to be x64. The rest are the default settings for the sample 'select'. I have never experienced that error before, nor do I find any reference to it. Can you please try to compile one of the other DB2 samples like the connect one? I just want to see whether the error is specifc to this project or it is a general problem with VS2022.
What Visual COBOL 8.0 patch level are you testing with? I am using the current one which is Patch Update 6.
Mine looks the same as yours on the COBOL tab. The only property I changed was the configuration to be x64. The rest are the default settings for the sample 'select'. I have never experienced that error before, nor do I find any reference to it. Can you please try to compile one of the other DB2 samples like the connect one? I just want to see whether the error is specifc to this project or it is a general problem with VS2022.
What Visual COBOL 8.0 patch level are you testing with? I am using the current one which is Patch Update 6.
Hi Chris,
Tried the connect sample..
Build started...
------ Build started: Project: Connect, Configuration: Debug x86 ------
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Connect\\Connect.cbl (1,1-2) : error COBDB0006 : Required DB software 'db2agapi' could not be found.SQL processing cannot continue.
* Compiling "C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Connect\\Connect.cbl"
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Connect\\Connect.cbl (60,15-22) : error COBCH0012 : Operand sqlcode is not declared
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Connect\\Connect.cbl (63,25-33) : error COBCH0012 : Operand sqlerrmc is not declared
COBOL compile: 0 item(s) succeeded or up-to-date, 1 failed.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
========== Build started at 2:15 PM and took 01.501 seconds ==========
Hi Chris,
Tried the connect sample..
Build started...
------ Build started: Project: Connect, Configuration: Debug x86 ------
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Connect\\Connect.cbl (1,1-2) : error COBDB0006 : Required DB software 'db2agapi' could not be found.SQL processing cannot continue.
* Compiling "C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Connect\\Connect.cbl"
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Connect\\Connect.cbl (60,15-22) : error COBCH0012 : Operand sqlcode is not declared
C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Connect\\Connect.cbl (63,25-33) : error COBCH0012 : Operand sqlerrmc is not declared
COBOL compile: 0 item(s) succeeded or up-to-date, 1 failed.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
========== Build started at 2:15 PM and took 01.501 seconds ==========
Change the configuration to X64...
Change the configuration to X64...

What Visual COBOL 8.0 patch level are you testing with? I am using the current one which is Patch Update 6.
What Visual COBOL 8.0 patch level are you testing with? I am using the current one which is Patch Update 6.
How can I find out that ? is there a command for that ?
How can I find out that ? is there a command for that ?
Open up the Windows Control Panel->Programs and Features and click on the link for view installed updates
Open up the Windows Control Panel->Programs and Features and click on the link for view installed updates

That is the base product version. To see the updates click on the View Installed updates link

That is the base product version. To see the updates click on the View Installed updates link


You are using the base release of Visual COBOL 8.0 with no patch updates installed. I removed my patch update and tested with the same version as you and it still works fine for me. The differences I see is that you are using DB2 11.5.4 and I am using 11.5.8 and that you are using VS2022 Community and I am using Enterprise.
You stated that you could get this to compile from the command line.
What command did you use?
What type of command prompt were you using?, i.e 32-bit, 64-bit, Visual COBOL prompt or standard system command prompt?
You are using the base release of Visual COBOL 8.0 with no patch updates installed. I removed my patch update and tested with the same version as you and it still works fine for me. The differences I see is that you are using DB2 11.5.4 and I am using 11.5.8 and that you are using VS2022 Community and I am using Enterprise.
You stated that you could get this to compile from the command line.
What command did you use?
What type of command prompt were you using?, i.e 32-bit, 64-bit, Visual COBOL prompt or standard system command prompt?
OK. Thanks. I will try this after updating my Db2 version.
Regarding command line for such things (COBOL with embedded Db2) I normally use Db2 command window (admin) and use / customize IBM provided batch cmd files like bldapp normally stored in: C:\\Program Files\\IBM\\SQLLIB\\samples\\cobol_mf.
To get these one working I may have to modify as mandatory COBOL paragraphs are missing.
Will try that later this week.
OK. Thanks. I will try this after updating my Db2 version.
Regarding command line for such things (COBOL with embedded Db2) I normally use Db2 command window (admin) and use / customize IBM provided batch cmd files like bldapp normally stored in: C:\\Program Files\\IBM\\SQLLIB\\samples\\cobol_mf.
To get these one working I may have to modify as mandatory COBOL paragraphs are missing.
Will try that later this week.
So you haven't successfully compiled the Select.cbl sample from a command prompt but instead the IBM provided samples work?
We would like you to try compiling the Select sample from both the 32-bit and 64-bit Visual COBOL command prompt in order to determine if this is an overall environment issue or it is just an issue when compiling within Visual Studio.
Navigate from the Windows Start menu to the group Micro Focus Visual COBOL and open up a Visual COBOL 64-bit command prompt. change directories so that the Select sample is your current directory.
This is located in: C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select>
Then execute the following 2 commands:
cobol select.cbl DB2(DB=SAMPLE);
cbllink select.obj
Does this work?
Then try it with a 32-bit Visual COBOL command prompt but before you execute the 2 commands run the following:
LIB=C:\\Program Files\\IBM\\SQLLIB\\lib\\Win32;%LIB%
then run the commands. Does this work?
Thanks.
So you haven't successfully compiled the Select.cbl sample from a command prompt but instead the IBM provided samples work?
We would like you to try compiling the Select sample from both the 32-bit and 64-bit Visual COBOL command prompt in order to determine if this is an overall environment issue or it is just an issue when compiling within Visual Studio.
Navigate from the Windows Start menu to the group Micro Focus Visual COBOL and open up a Visual COBOL 64-bit command prompt. change directories so that the Select sample is your current directory.
This is located in: C:\\Users\\Public\\Documents\\Micro Focus\\Visual COBOL\\Samples\\SQL\\db2ecm\\Select>
Then execute the following 2 commands:
cobol select.cbl DB2(DB=SAMPLE);
cbllink select.obj
Does this work?
Then try it with a 32-bit Visual COBOL command prompt but before you execute the 2 commands run the following:
LIB=C:\\Program Files\\IBM\\SQLLIB\\lib\\Win32;%LIB%
then run the commands. Does this work?
Thanks.
got this in Visual COBOL 64-bit command prompt


Works fine in Visual COBOL 32-bit command prompt :))
Thanks
got this in Visual COBOL 64-bit command prompt


Works fine in Visual COBOL 32-bit command prompt :))
Thanks
Updated Db2

Now it's working OK within Visual Studio...able to build & run...Just tested the connect project.

So looks like issue was with the Db2 version/environment variables.
Many thanks for your help.