COBOL LINUX - when compiling, receiving errors

When attempting to compile I get these numerous errors as seen below:

user@DESKTOP-57BGLNH:~$ pwd
user@DESKTOP-57BGLNH:~$ ls
COBOL               testdoc.cob
user@DESKTOP-57BGLNH:~$ cobc -x testdoc.cob
assignment1.cob:1: error: invalid indicator 'f' at column 7
assignment1.cob:2: error: invalid indicator 'm' at column 7
assignment1.cob:4: error: invalid indicator 'n' at column 7
assignment1.cob:5: error: invalid indicator 'u' at column 7
assignment1.cob:7: error: invalid indicator 'i' at column 7
assignment1.cob:8: error: invalid indicator 'g' at column 7
assignment1.cob:10: error: invalid indicator 'u' at column 7
assignment1.cob:11: error: invalid indicator 'a' at column 7
assignment1.cob:12: error: invalid indicator 'k' at column 7
assignment1.cob:14: warning: line not terminated by a newline [-Wothers]
assignment1.cob:14: error: invalid indicator 'r' at column 7
assignment1.cob:9: error: PROGRAM-ID header missing
assignment1.cob:9: error: PROCEDURE DIVISION header missing
assignment1.cob:9: error: syntax error, unexpected PICTURE

*For context,

I am in VSC, I open the remote window and create a new file with the following code:

identification division.
program-id. Assignment1.

environment division.
configuration section.

data division.
working-storage section.
01 out pic x(11) value "Hello World".
procedure division.
    display out.

end program Assignment1.

File> Save.

Open new terminal, and use pwd and ls to ensure I am in the right directory, as you can see "/home/user" is the directory where file "testdoc.cob" is located, as per ls command. I then use "cobc -x testdoc.cob" to compile, and then I get these series of errors. Why is this? and where am I going wrong?

Ive tried repeating the process in new folders with different .extentions, all end in the same result.


  • This is code in free-form reference-format, which was standardized with COBOL2002, the "historical" fixed-form reference-format uses a layout in which there is a "sequence" column 1-6, an indicator column 7 and depending on the standard used the code goes to column 12-72 or also includes 8-11 (where previously only some declarations went).
    "Old" code you see will be often in fixed-form reference-format and as some COBOL tools still only support this format, you may consider still using it for new code. When coding in a group (or a "COBOL shop") you will commonly have rules about what to use.

    To learn more about formats see the Programmer's Guide for the compiler you use.

    GnuCOBOL 3.2 compiles this with

    assignment.cob:1: note: free format detected

    for earlier versions either explicit set it by passing the command line option --free or, as noted in the Programmer's Guide, use a compiler directive:


    (that starts in column 8) is the COBOL standard way to set this, Micro Focus COBOL (which has quite a big market in COBOL on PC) defines it as:


    (GnuCOBOL supports both)