Menu

How to install GnuCobol on my Mac

Steve
2023-08-30
2023-09-01
1 2 > >> (Page 1 of 2)
  • Steve

    Steve - 2023-08-30

    Hi all, I downloaded the cobol file onto my Mac and I don't know what to do with it. I have already installed HomeBrew via the terminal .

    How do I install the GnuCobol? I downloaded the file gnucobol-3.2.tar.xz and it's in my download directory.
    How do I install this? Do I need to do it via terminal ?

    I dont realy know how to use dthe commands in terminal.

    Thank you good people.

    Steve

     
    • Simon Sobisch

      Simon Sobisch - 2023-08-30

      If you run on Mac with HomeBrew and don't want to change GnuCOBOL itself or use another ORGANIZATION INDEXED handler than BDB, then the most reasonable way to install GnuCOBOL is to just run brew install gnu-cobol in a terminal and you're done (it was updated to 3.2 some weeks ago and was adjusted to contain every feature last week).

      If you ever want to try GnuCOBOL 4 (runs quite stable but has no stable API, so updating that may result in the need to recompile all COBOL sources), then you can also brew install --HEAD gnu-cobol [works and passes all internal and NIST85 tests, just as 3.2 does (which does have other internal tests, of course)].

      After both options you can then use cobc from everywhere; you can also do brew install --cask vscodium and execute the compiler from there (and have a nice editing when installing the right extensions, but that's a different topic handled in other discussion threads already).

       
  • Steve

    Steve - 2023-08-30

    Great look like it installed but when I type cobc it is looking for a n input file.

    stevelaba@Steves-iMac ~ % brew install gnu-cobol
    ==> Downloading https://formulae.brew.sh/api/formula.jws.json

    ################################################################### 100.0%

    ==> Downloading https://formulae.brew.sh/api/cask.jws.json

    ################################################################### 100.0%

    ==> Fetching dependencies for gnu-cobol: ca-certificates, openssl@3, berkeley-db, gmp and json-c
    ==> Fetching ca-certificates
    ==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-

    ################################################################### 100.0%

    ==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:a3

    ################################################################### 100.0%

    ==> Fetching openssl@3
    ==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.1.2-1

    ################################################################### 100.0%

    ==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/blobs/sha256:2bea791e

    ################################################################### 100.0%

    ==> Fetching berkeley-db
    ==> Downloading https://ghcr.io/v2/homebrew/core/berkeley-db/manifests/18.1.40_2

    ################################################################### 100.0%

    ==> Downloading https://ghcr.io/v2/homebrew/core/berkeley-db/blobs/sha256:a6b047

    ################################################################### 100.0%

    ==> Fetching gmp
    ==> Downloading https://ghcr.io/v2/homebrew/core/gmp/manifests/6.2.1_1

    ################################################################### 100.0%

    ==> Downloading https://ghcr.io/v2/homebrew/core/gmp/blobs/sha256:4c6488dfd53b82

    ################################################################### 100.0%

    ==> Fetching json-c
    ==> Downloading https://ghcr.io/v2/homebrew/core/json-c/manifests/0.17

    ################################################################### 100.0%

    ==> Downloading https://ghcr.io/v2/homebrew/core/json-c/blobs/sha256:6964da23ee0

    ################################################################### 100.0%

    ==> Fetching gnu-cobol
    ==> Downloading https://ghcr.io/v2/homebrew/core/gnu-cobol/manifests/3.2-1

    ################################################################### 100.0%

    ==> Downloading https://ghcr.io/v2/homebrew/core/gnu-cobol/blobs/sha256:b284db83

    ################################################################### 100.0%

    ==> Installing dependencies for gnu-cobol: ca-certificates, openssl@3, berkeley-db, gmp and json-c
    ==> Installing gnu-cobol dependency: ca-certificates
    ==> Pouring ca-certificates--2023-08-22.ventura.bottle.tar.gz
    ==> Regenerating CA certificate bundle from keychain, this may take a while...
    🍺 /usr/local/Cellar/ca-certificates/2023-08-22: 3 files, 221.6KB
    ==> Installing gnu-cobol dependency: openssl@3
    ==> Pouring openssl@3--3.1.2.ventura.bottle.1.tar.gz
    🍺 /usr/local/Cellar/openssl@3/3.1.2: 6,495 files, 30.0MB
    ==> Installing gnu-cobol dependency: berkeley-db
    ==> Pouring berkeley-db--18.1.40_2.ventura.bottle.tar.gz
    🍺 /usr/local/Cellar/berkeley-db/18.1.40_2: 44 files, 5.9MB
    ==> Installing gnu-cobol dependency: gmp
    ==> Pouring gmp--6.2.1_1.ventura.bottle.tar.gz
    🍺 /usr/local/Cellar/gmp/6.2.1_1: 21 files, 3.3MB
    ==> Installing gnu-cobol dependency: json-c
    ==> Pouring json-c--0.17.ventura.bottle.tar.gz
    🍺 /usr/local/Cellar/json-c/0.17: 33 files, 335.6KB
    ==> Installing gnu-cobol
    ==> Pouring gnu-cobol--3.2.ventura.bottle.1.tar.gz
    🍺 /usr/local/Cellar/gnu-cobol/3.2: 74 files, 3MB
    ==> Running brew cleanup gnu-cobol...
    Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
    Hide these hints with HOMEBREW_NO_ENV_HINTS (see man brew).
    stevelaba@Steves-iMac ~ % cobc
    cobc: error: no input files
    stevelaba@Steves-iMac ~ % cobc
    cobc: error: no input files
    stevelaba@Steves-iMac ~ %

     
    • Vincent (Bryan) Coen

      It appears you have installed GC.

      To test lightly try :

      cobc -v   or (or both)
      cobc -i

      On 30/08/2023 21:14, Steve wrote:

      |man brew|).
      -- cut --

      stevelaba@Steves-iMac ~ % cobc
      cobc: error: no input files
      stevelaba@Steves-iMac ~ % cobc
      cobc: error: no input files
      stevelaba@Steves-iMac ~ %

       
  • Steve

    Steve - 2023-08-30

    I get this
    stevelaba@Steves-iMac ~ % cobc -v
    cobc (GnuCOBOL) 3.2.0
    Built Aug 25 2023 15:20:58 Packaged Jul 28 2023 17:02:56 UTC
    C version "Apple LLVM 14.0.3 (clang-1403.0.22.14.1)"
    loading standard configuration file 'default.conf'
    cobc: error: no input files
    stevelaba@Steves-iMac ~ % cobc -i
    cobc (GnuCOBOL) 3.2.0
    Copyright (C) 2023 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
    Built Aug 25 2023 15:20:58
    Packaged Jul 28 2023 17:02:56 UTC
    C version "Apple LLVM 14.0.3 (clang-1403.0.22.14.1)"

    build information
    build environment : x86_64-apple-darwin22.4.0
    CC : clang
    C version : "Apple LLVM 14.0.3 (clang-1403.0.22.14.1)"
    CPPFLAGS : -I/usr/local/Cellar/gmp/6.2.1_1/include
    CFLAGS : -O2 -pipe
    LD : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
    LDFLAGS :

    GnuCOBOL information
    COB_CC : clang
    COB_CFLAGS : -pipe -I/usr/local/Cellar/gmp/6.2.1_1/include
    -I/usr/local/Cellar/gnu-cobol/3.2/include
    -Wno-unused -fsigned-char -Wno-pointer-sign
    -Qunused-arguments
    -Wno-deprecated-non-prototype
    COB_DEBUG_FLAGS : -ggdb3 -fasynchronous-unwind-tables
    COB_LDFLAGS :
    COB_LIBS : -L/usr/local/Cellar/gnu-cobol/3.2/lib -lcob
    COB_CONFIG_DIR : /usr/local/Cellar/gnu-cobol/3.2/share/gnucobol/config
    COB_COPY_DIR : /usr/local/Cellar/gnu-cobol/3.2/share/gnucobol/copy
    COB_MSG_FORMAT : GCC
    COB_OBJECT_EXT : o
    COB_MODULE_EXT : dylib
    COB_EXE_EXT :
    64bit-mode : yes
    BINARY-C-LONG : 8 bytes
    endianness : little-endian
    native EBCDIC : no
    extended screen I/O : ncurses
    variable file format : 0
    sequential file handler : built-in
    indexed file handler : BDB
    mathematical library : GMP
    XML library : libxml2
    JSON library : json-c
    stevelaba@Steves-iMac ~ %

     
    👍
    1
    • Vincent (Bryan) Coen

      The compiler is fully installed.

      Now you just need to do some programming in Cobol and submit the program
      source to cobc

      Make sure you download the manual Programming Guide.from the sourceforge
      website so you can print it out or just read the .pdf file.

      There is also a Sample Programs manual as well and look at the Contrib
      area where there is more programs written in Cobo for you to examine and
      compile & run.

       
  • Steve

    Steve - 2023-08-30

    Hi, so how do I start the new program? Is there an editing part to GnuCobol? Is there a manual on how to get started with GnuCobol? I can follow the documentation on the syntax for Cobol but where do i create the program code and then compile that file?

    Thanks
    Steve

     

    Last edit: Steve 2023-08-31
    • Vincent (Bryan) Coen

      On 31/08/2023 00:34, Steve wrote:

      Hi, so how do I start the new program? Is there an editing part to
      GnuCobol? Is there a manual on how to get started with GnuCobol?

      Get and read the Gnucobol Programmers Guide and you can get it via :

      https://gnucobol.sourceforge.io/guides.html

      select the first three for Letter and the next three for A4 format

      These manuals are NOT ideal for learning Cobol so I suggest you get a
      book on it or download one of the many videos on learning.

      Another thing you can do assuming you have programming experience is to
      look at some of the programs in stored in the Contrib area at  :

      https://sourceforge.net/p/gnucobol/contrib/HEAD/tree/trunk/tools/

      Look at flightlog    which as the name suggests is a Flight log book
      program to record all flights for all aircrew.

      If you want a full blown set of programs for a commercial application
      take a look at

      https://sourceforge.net/projects/acas/

      grab the ACAS-Nightly.rar

       
  • Anonymous

    Anonymous - 2023-08-31

    Hi again. I'm looking for a quick start on what editor to use and then saving the Cobol progra and then compiling it. I can see that VI is avalable in Terminal on my Mac.
    Is that information in the guides yu are mentioning.

    Sorry but I have not used the Terminal on my Mac before and its a bit criptic to me.

    I used to be a Cobol programer back in the 80's and 90's.

    I just trying to brush up on the Cobol.

    Thank you for being so helpful.

    Steve

     
    • Vincent (Bryan) Coen

      Steve - please sign up to an account on SF - It will save you having to
      wait for your posts to be moderated.
      It is free.

      On 31/08/2023 17:53, noreply@sourceforge.net wrote:

      Hi again. I'm looking for a quick start on what editor to use and then
      saving the Cobol progra and then compiling it. I can see that VI is
      avalable in Terminal on my Mac.
      Is that information in the guides yu are mentioning.

      You can use ANY text editor available on your Mac and you can use the
      IDE available via the SF site - there are two and one has had
      development discontinued but still works but not sure it is available
      for the mac.

      I tend to use kate under Linux which may well be available on Mac but
      the Mac does have other gui based one's that can handle Cobol and its
      syntax.

      For these they are ALL Gui based so no terminal used but that is used to
      compile programs if not using a Gui IDE but that said I find it quicker
      to use a terminal windows as I can build a quick bash (or other) script
      to compile more than one source file at a time.
      Another option here is to create a makefile for use with the development
      program make. Your choice.

      I do have  a Mac Pro (2008) but do not use it day to day or even month
      to month - must get around to selling it as was only bought for doing
      some minor testing and to see what OSX was about compared to Linux..

      Sorry but I have not used the Terminal on my Mac before and its a bit
      criptic to me.

      I used to be a Cobol programer back in the 80's and 90's.

      I just trying to brush up on the Cobol.

      Thank you for being so helpful.

      Steve

       
    • Simon Sobisch

      Simon Sobisch - 2023-08-31

      As noted, if you want an extended editor for several programming languages, you can brew install vscodium (there are a bunch of tutorials online how to use VSCodium/vscode).

      When you install a COBOL extension, you get nice highlighting and, depending on the extension, some features.

      It may be useful if you additional install the gnucobol.debug extension, its default is to compile with "cobc" itself when you use the run/debug command... and it allows debugging COBOL, too.

       
  • Steve

    Steve - 2023-08-31

    Ok this is getting a bit complicated for what I want to do.

    What is IDE available via the SF site. Is this an editor?

     
    • Mickey White

      Mickey White - 2023-08-31

      Hi Steve, welcome to GnuCOBOL. I do not have a Macintosh so I do not know much about this. I looked a site on the www and to me it appears Ultra Edit would be the easiest to learn.
      Here.

       
  • Steve

    Steve - 2023-08-31

    Well I compiled a test program and I got lots of errors.

    Looks like the code is not lined up or something. does anyone notice what I'm doing wrong?

    IDENTIFICATION DIVISION.
    PROGRAM-ID. helloworld.
    PROCEDURE DIVISION.
                  DISPLAY 'Hello World!'.
                 END PROGRAM helloworld.
    
    stevelaba@Steves-iMac Cobolprg % cobc helloworld
    helloworld:1: note: free format detected
        1 > ????..
        2 | ..
        3 | ???2..
    helloworld:2: warning: source text exceeds 512 bytes, will be truncated [-Wothers]
        1 | ????..
        2 > ..
        3 | ???2..
        4 | ..
    helloworld:3: warning: source text exceeds 512 bytes, will be truncated [-Wothers]
        1 | ????..
        2 | ..
        3 > ???2..
        4 | ..
        5 | ..
    helloworld:4: warning: source text exceeds 512 bytes, will be truncated [-Wothers]
        2 | ..
        3 | ???2..
        4 > ..
        5 | ..
    helloworld:5: warning: source text exceeds 512 bytes, will be truncated [-Wothers]
        3 | ???2..
        4 | ..
        5 > ..
    helloworld:1: error: PROGRAM-ID header missing
        1 > ????..
        2 | ..
        3 | ???2..
    helloworld:1: error: ENVIRONMENT DIVISION header missing
    helloworld:1: error: CONFIGURATION SECTION header missing
    helloworld:1: error: SPECIAL-NAMES header missing
    helloworld:1: error: invalid system-name '????'
    helloworld:1: error: invalid symbol '' - skipping word
    helloworld:1: error: invalid symbol '' - skipping word
    helloworld:1: error: invalid symbol '?' - skipping word
    helloworld:1: error: invalid symbol '?' - skipping word
    helloworld:2: error: invalid symbol '_' - skipping word
        1 | ????..
        2 > ..
        3 | ???2..
        4 | ..
    helloworld:2: error: invalid symbol '
                                         ' - skipping word
    helloworld:3: error: invalid symbol '' - skipping word
        1 | ????..
        2 | ..
        3 > ???2..
        4 | ..
        5 | ..
    helloworld:4: error: invalid system-name '?'
        2 | ..
        3 | ???2..
        4 > ..
        5 | ..
    helloworld:4: error: invalid symbol '' - skipping word
    helloworld:4: error: invalid symbol '' - skipping word
    ' - skipping wordor: invalid symbol '
    helloworld:5: error: invalid system-name '?'
        3 | ???2..
        4 | ..
        5 > ..
    helloworld:5: error: invalid symbol '
                                         ' - skipping word
    helloworld:6: error: syntax error, unexpected end of file, expecting CRT or Identifier
        4 | ..
        5 | ..
    helloworld:6: error: syntax error, unexpected end of file
    
     

    Last edit: Simon Sobisch 2023-09-01
    • Mickey White

      Mickey White - 2023-08-31

      Download the attached file to your cobol directory where your current helloworld is at.
      Then compile with: cobc -x helloworld1.cbl

       
    • Simon Sobisch

      Simon Sobisch - 2023-09-01

      Note: this output is the reason for [feature-requests:#443] (mostly done, need to add testcases and commit after the other changes already done after 3.2)

       

      Related

      Wish List: #443

    • Simon Sobisch

      Simon Sobisch - 2023-09-01

      Just to make that clear: you likely have compiled the original program once, but then above you have compiled the binary

      cobc helloworld vs. cobc helloworld.cbl

      As noted in the mentioned feature request this will be checked in the next version, resulting in

      cobc helloworld
      cobc: helloworld: is a binary file
      
       
  • Steve

    Steve - 2023-08-31

    Hi Mickey, I just did that and this is what I get
    There was no output from the compiler but it created the file helloworld1

    stevelaba@Steves-iMac Cobolprg % cobc -x helloworld1.cbl
    stevelaba@Steves-iMac Cobolprg % ls
    helloworld      helloworld.dylib    helloworld1.cbl
    helloworld.cbl      helloworld1
    stevelaba@Steves-iMac Cobolprg % 
    
     

    Last edit: Simon Sobisch 2023-09-01
    • Mickey White

      Mickey White - 2023-08-31

      now to run the program just compiled, just type in: helloworld1
      OR maybe: .helloworld1
      OR maybe: ./helloworld1

       

      Last edit: Simon Sobisch 2023-09-01
    • Simon Sobisch

      Simon Sobisch - 2023-09-01

      You obviously have helloworld compiled both with and without -x.

      To run the "main" executable: ./helloworld.
      To run the module, which is also CALLable: cobcrun helloworld1 (will load the program from helloworld.dylib)

       
  • Steve

    Steve - 2023-09-01

    That worked Mickey. You people on this site are unbelievably helpful

     
    • Mickey White

      Mickey White - 2023-09-01

      welcome. I think your program had some invalid end-of-line or carriage-return issues.
      Keep on writting and compiling. !

       
  • Anonymous

    Anonymous - 2023-09-01

    That worked Mickey. You people on this site are unbelievably helpful
    When I compile my program it seems to be looking for and end of line or something.
    I put in 2 more display statements and this is what I get.

    stevelaba@Steves-iMac cobolprg % cobc -x helloworld.cbl
    helloworld.cbl:9: warning: line not terminated by a newline [-Wmissing-newline]
        7 |            DISPLAY 'Hello World! 2'.
        8 |             DISPLAY 'Hello World! 3'.
        9 >           END PROGRAM helloworld.<EOF>
    

    The program does work so could this be because of the editor I used to create the code in?

     

    Last edit: Simon Sobisch 2023-09-01
    • Mickey White

      Mickey White - 2023-09-01

      I think so. can you copy the one I gave you and do some edits on it, add some lines and then try to compile?
      Do you have a windows box?

       
    • Simon Sobisch

      Simon Sobisch - 2023-09-01

      This is likely related to your editor. This warning says that some tools will not be able to process that last line, correctly because the end of line marker is missing.

      Just go to its end and press ENTER, then that warning goes away.

       
1 2 > >> (Page 1 of 2)

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.