Menu

Compile a COBOL source with VSCODE or VSCODIUM

2020-06-13
2020-06-15
  • Eugenio Di Lorenzo

    Hi to All,
    what is the easiest way to compile a program with "cobc" and GnuCOBOL when you are editing a COBOL source with VSCODE or VSCODIUM?
    can Someone give a description step by step.
    Can it be done similarly to what is done with OpenCobolIDE?
    Example use F5 or click an icon, the compilation starts, then the system displays the errors ... etc etc

     
  • Simon Sobisch

    Simon Sobisch - 2020-06-13

    The easiest way is to:

    • ensure cobc is available in "PATH" and usable from the command line
    • install vscodium
    • use the extension search to install the cobol extension from bitlang (and if you like to also the theme)
    • possibly also install one of the debuggers (the extension search only shows gnucobol-debug but should soon be companioned with the one from Camelian.Systems [this one would also need cbl-dbg installed and its cobcd reachable from a command line])

    Then possibly adjust the extensions settings (like search folders for copybooks), then use "build" which will suggest you to create a task definition, similar use "debug" and create the suggested debug configuration.

     
  • Marty Heyman

    Marty Heyman - 2020-06-13

    We're sorry but the publication of the installer for Camelian.Systems's GnuCOBOL Debugging Extensions to the vsix.org site will take a few more days. You can go to download the file. You then point the extensions tools at the file to install. You'd need to have the Extensions package installed as Simon points out. There are installers by clicking on the Windows link on that page.

    Keep us posted and we're glad to help.

     
    • Simon Sobisch

      Simon Sobisch - 2020-06-13

      Found it: https://camelian.systems/pages/downloads.html (edit: now https://cobolworx.com/pages/downloads.html)
      [if you just follow the links on the camelian page you end on a downloads.md, I think somewhere was a similar broken link, if I ever it it then I now know to replace the "md" to "html, but I guess you're faster in updating the page - related to that: it misses a link to the sources [gitea] for the cbl-dbg package and for the cbl-dbg.vsix]

       

      Last edit: Simon Sobisch 2022-01-06
      • Marty Heyman

        Marty Heyman - 2020-06-13

        Got it … shouldn’t take very long to fix

         

        Last edit: Simon Sobisch 2020-06-14
        • Simon Sobisch

          Simon Sobisch - 2020-06-14

          Verified the download link as fixed. As this is a topic drift I'll delete that part of the discussion soon.
          Things open: https://camelian.systems/pages/cbl-gdb.html still points to http://gitea.camelian.systems/cbl-gdb which should be http://gitea.camelian.systems/Camelian.Systems instead and this one should also have a second repository for the vsix extension.

           
          • Marty Heyman

            Marty Heyman - 2020-06-14

            I got half of it this morning. @rdubner needs to remote the repository to gitea.camelian.systems. Probably tomorrow. Then I will change the pointer and or add that link to the site.

             

            Last edit: Simon Sobisch 2020-06-14
  • Eugenio Di Lorenzo

    Thanks a lot to both but my question was much more basic.
    I simply want to compile a program from VSCODE / VSCODIUM before thinking about extensions and debugging.
    Which is the command to use?
    Which parameters should I set?
    Where do I see compiler error messages?

     
    • Simon Sobisch

      Simon Sobisch - 2020-06-13

      Without a COBOL extension (it is not a built-in language) you won't have any of the features OCIDE brought you (syntax highlighting, an outline and the option to show/peek a definition, to name a view).

      The most basic option is to use (possible open before) the internal terminal and then type as you'd do on the command line.

      The more useful way is to use the "build" command (the commands are in the upper area), you'll be then prompted with the option to define a task (which will then run in the integrated terminal, showing all messages and you can already click on those).
      You'd then go on with defining a problem matcher so the build task will scan the terminal output and recognize the messages, moving them to the "problems" panel and also shown in the outline, explorer, and highlighted in the editor.

      The build task can be simplified by an extension as this can bring in templates (I think the bitlang cobol brings one for the task "cobc single file", for example), removing the need to create it all on your own; and it also features problemMatchers so you don't have to define them on your own either.

      In general you'd have to think what kind of build system you want to use (the way above would be "complile each file manually on its own"), if you use a make based build system you could for example always trigger this (and as "old" files won't be touched you get a quick "build all", if you want even on a save and have all "problems" listed in your workspace [if that wasn't clear: in my humble opinion that is definitely the best way to go]).

       
      • Eugenio Di Lorenzo

        thanks to the indications I received and a few attempts, I managed to make simple compilations of a cobol source with VSCODE.
        You can find attached a document that illustrates the steps to be taken for anyone interested.

         
        • Simon Sobisch

          Simon Sobisch - 2020-06-14

          Looks like you're using GnuCOBOL 3, in this case adjust the problemmatcher to gnucobol3-cobc and you'll see the "problems" recognized correctly.

           
          • Eugenio Di Lorenzo

            Thanks... it works fine !
            (do you know where to find some documentation abut the problemmatcher ?

            Now I need to execute the program after compilation. Any hint ?

             
            • Simon Sobisch

              Simon Sobisch - 2020-06-14

              You could either define two build tasks (only one as default, of course!) and one of this using -j in the argument list.

              Note: the problemMatcher don't work correctly when using a foreign language for the messages, https://github.com/microsoft/vscode/issues/97256 is about fixing this - just in case someone wants to vote for it, still 19 votes missing...

              The problemMatcher are part of the tasks therefore you find them with searching the net for "vscode tasks", see https://code.visualstudio.com/Docs/editor/tasks.
              bitlang.cobol ships a set of additional pre-defined problem matchers, you now find it in its documentation (and can see them in its package definition under problemPatterns).

               

              Last edit: Simon Sobisch 2020-06-15
              • Eugenio Di Lorenzo

                Updated Version of VSCODE/VSCODIUM Basic Configuration for GnuCOBOL 3.x.

                 
                • Simon Sobisch

                  Simon Sobisch - 2020-06-15

                  I highly suggest to open the explorer view [your screens are on the extension view] and then open "outline" :-) Note: you'll even see the problems there (and in the actual explorer).

                  And possibly to get rid of some of the COBOL extensions if you don't need all, otherwise disable the ones you don't need now.

                  In general it may be much easier to add the final tasks.json definiition you ended up with than clicking multiple times? Just an idea...

                   
        • Arnold Trembley

          Arnold Trembley - 2020-06-15

          There is a page of COBOL related plugins for VSCODE:
          https://marketplace.visualstudio.com/search?term=COBOL&target=VSCode&category=All%20categories&sortBy=Relevance

          At least one of them claims to integrate GnuCOBOL with the Gnu debugger:
          https://marketplace.visualstudio.com/items?itemName=OlegKunitsyn.gnucobol-debug

           
          • Simon Sobisch

            Simon Sobisch - 2020-06-15

            There is a page of COBOL related plugins for VSCODE

            Yes - also see https://open-vsx.org/?search=cobol (the vs market is "per license", other than a browser, only allowed to be used with proprietary products from Microsoft and the Open VSX Registry is also the default extension provider for VSCodium and other free builds of the "vscode" project). The extensions found there are for the "vscode" project and therefore work both in VSCodium and VSCode (while you find proprietary extensions in the marketplace which often don't work on VSCodium...).

            At least one of them claims to integrate GnuCOBOL with the Gnu debugger

            Also correct, https://open-vsx.org/extension/OlegKunitsyn/gnucobol-debug integrates without additional machine-installed tools and also works with the GDB version in Arnold's packages.
            Because of the way it is written also works with GnuCOBOL 2 but likely misses some features that the cbl-dbg "frontend" has. We'll see once the second one is available in the marketplace.

             

            Last edit: Simon Sobisch 2020-06-15

Anonymous
Anonymous

Add attachments
Cancel