Since I am waiting for my new PC to be delivered and I am sometimes inpatient, I wanted to try some COBOL programming on my MacBook.

Knowing that COBOL is a very old language, I was prepared for some effort to get things going.

Surprisingly it was quite easy. Looking for something to train basics, I found GNU-COBOL.

GNU-COBOL is an open source implementation of a COBOL compiler available for MacOS.

The installation

Let me say this at the beginning. If you want to safe yourself the installation and just have a quick look, I found a COBOL compiler and IDE that runs in your web browser.

https://www.tutorialspoint.com/compile_cobol_online.php

It is based on GnuCOBOL (former OpenCOBOL) as well.

However, let's proceed with installing the compiler.

Open a console and type the following to install GNU-COBOL.

brew install gnu-cobol

First HomeBrew will install dependencies for this package.

==> Installing dependencies for gnu-cobol: berkeley-db, gmp

Everything went fine here. After installing the dependencies, gnu-COBOL was installed successfully.

Light Weight IDE

I guess I could have stopped there, but I wanted at least a light weight IDE for COBOL.

Doing everything manually like the 7 free columns in the beginning of each line would have been a real pain.

The IDE I use is called OpenCobolIDE.

It can be installed from their website via dmg, but you need to have Python 3 installed.

brew install python3

The installation of python 3 via HomeBrew failed at first, since my users/local directory did not allow me to create directories in it.

It failed at the following step.

==> make html

Error: An unexpected error occurred during the `brew link` step

The formula built, but is not symlinked into /usr/local

Permission denied @ dir_s_mkdir - /usr/local/Frameworks

Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

I found a solution for that.

sudo mkdir /usr/local/Frameworks

sudo chown $(whoami):admin /usr/local/Frameworks

brew install python3

The above creates the missing directory and allows write access.

It is not recommended to allow write access in usr/local, since it seems the OS did not allow this by default.

I installed the IDE via HomeBrew as well, since the post I found the installation instructions on suggested to do that, but I suggest you use the installer.

brew install pyqt5 --using python3
==> Installing dependencies for pyqt: qt, python@2, sip

pip3 install OpenCobolIDE --upgrade
Collecting OpenCobolIDE

  Downloading https://files.pythonhosted.org/packages/30/19/bbcf13bca5c0baf34ef5aad2763f8ab92c1e6a9653703cbcda38af62e092/OpenCobolIDE-4.7.6.tar.gz (12.9MB)

    100% |████████████████████████████████| 12.9MB 959kB/s 

Building wheels for collected packages: OpenCobolIDE

  Running setup.py bdist_wheel for OpenCobolIDE ... error

  Complete output from command /usr/local/opt/python/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/5p/gvq_4ycn5gq1yzl82kt7yr680000gn/T/pip-install-70jzuc3d/OpenCobolIDE/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/5p/gvq_4ycn5gq1yzl82kt7yr680000gn/T/pip-wheel-ztgx4vwg --python-tag cp36:

  Traceback (most recent call last):

    File "<string>", line 1, in <module>

    File "/private/var/folders/5p/gvq_4ycn5gq1yzl82kt7yr680000gn/T/pip-install-70jzuc3d/OpenCobolIDE/setup.py", line 61, in <module>

      raise RuntimeError("This setup.py does not support wheels")

  RuntimeError: This setup.py does not support wheels

  

  ----------------------------------------

  Failed building wheel for OpenCobolIDE

  Running setup.py clean for OpenCobolIDE

Failed to build OpenCobolIDE

Installing collected packages: OpenCobolIDE

  Running setup.py install for OpenCobolIDE ... done

Successfully installed OpenCobolIDE-4.7.6

Now we can run OpenCobolIDE using ...

openCobolIde

Cheers!