0

vscode error message

we are using cobol now, but this config error keeps on appearing and I do not know how to fix this thing. Any help would really mean alot. (Just a beginner and trying to learn vscode)

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38
Pharaoh
  • 13
  • 3
  • 1
    IS there anything "open" then please comment in the answer, if not mark the answer as "accepted = works best for me" - see https://stackoverflow.com/tour – Simon Sobisch Jan 10 '22 at 06:23

2 Answers2

0

This message is only presented in vscode's Terminal after you've entered a command there, it is actually not related to vscode.

The "common" way with vscode would be to create a vscode task for the compilation and configure a problem matcher, too, so vscode is able to parse the messages. For details see vscode docs "Integrate with External Tools via Tasks".

As the message is coming from the GnuCOBOL compiler it may be reasonable to check in its discussion board, which also includes a note how to use your setup of vscode with GnuCOBOL MinGW package, this would be your starting point, assuming D:\COBOL is the place where you have your sources (and this is the alos the workspaceFolder as in your screenshot), D:\COBOL\copy where your copybook reside and D:\GnuCOBOL where the MinGW package is:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "GnuCOBOL - cobc (compile single file)",
            "type": "shell",
            "command": "cobc",
            "args": [
                "-I${workspaceFolder}\\copy",
                "${file}"
            ],
            "problemMatcher": "$gnucobol3-cobc",
            "options": {
                "env": {
                    "COB_CFLAGS": "-I\"D:\\GnuCOBOL\\include\"",
                    "COB_CONFIG_DIR": "D:\\GnuCOBOL\\config",
                    "COB_COPY_DIR": "D:\\GnuCOBOL\\copy",
                    "COB_LDFLAGS": "-L\"D:\\GnuCOBOL\\lib\"",
                    "COB_LIBRARY_PATH": "D:\\GnuCOBOL\\extras",
                    "PATH": "D:\\GnuCOBOL\\bin:${env:PATH}"
                }
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Instead of directly calling cobc you could also call cobc.bat or similar, then create it with all your default options set there (or, if you use the official mingw packages, just call the set_env.cmd) then call the compiler.

Concerning "how to fix that message" - make sure you have the "config" directory of GnuCOBOL and have COB_CONFIG_DIR set to it either in the task definition or outside of vscode (for example by starting vscode from the "Developer prompt for GnuCOBOL MinGW" (which is the set_env.cmd distributed with it).

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38
0

Late, but perhaps worth it. Currently there is a cobenv.bat or .sh (if you are on linux). The whole path to the file may differ for me is this:

C:\msys64\mingw64\bin\cobenv.cmd

You'll notice that if you execute the file and run the compiler everything works fine, but once you close that bash the error shows up again.

That's because the scope of those variables was just that session. You may execute it every time you run the compiler or you can make those variables to persist on your system. In my case I did the later, modifying cobenv.cmd

But not those lines with the variable PATH.

So this lines, i.e., whenever we encounter this same three variables. For instance, after a certain if in that file we encounter:

  setx "COB_LIBRARY_PATH" "%MINGW_ROOT_PATH%lib\gnucobol%COB_LIBRARY_PATH%"
  setx "COB_COPY_DIR" "%MINGW_ROOT_PATH%share\gnucobol\copy"
  setx "COB_CONFIG_DIR" "%MINGW_ROOT_PATH%share\gnucobol\config"

Default value: set.

New value: setx.

Delete the = to comply with the correct syntax. Check the compiler with different new session.

SNR
  • 712
  • 1
  • 8
  • 22