4th October 2021

Installing IBM COBOL for Linux on Arch Linux

Task at hand: Install the 60-day trial of "IBM COBOL for Linux" on Arch Linux.

1. Download. Downloading the compiler is at IBM COBOL for Linux on x86 60-day Trial.

2. Unpacking. Downloaded file is marked as gzipped tar, but in actuality it is just a tar file:

$ file IBM_COBOL_V1.1.0_LINUX_EVAL.x86-64.tar.gz 
IBM_COBOL_V1.1.0_LINUX_EVAL.x86-64.tar.gz: POSIX tar archive (GNU)

Unpacking this tar-file provides 4 deb-files and 4 rpm-files. I picked the deb-files:

  1. Not required: cobol.cmp.license-eval.1.1.0_1.1.0.0-210903.864_amd64.deb
  2. Debugging part: cobol.dbg.1.1.0_1.1.0.0-210903.864_amd64.deb
  3. The compiler: cobol.cmp.1.1.0_1.1.0.0-210903.864_amd64.deb
  4. Runtime: cobol.rte.1.1.0_1.1.0.0-210903.864_amd64.deb

deb-files can be unpacked with ar, see How to extract a .deb file without opening it on Debian or Ubuntu Linux. I unpacked the four deb-files. Each deb-files contains

  1. Can be ignored: debian-binary
  2. Can be ignored: control.tar.gz
  3. data.tar.xz

File data.tar.xz is then extracted with tar xf. The resulting subdirectories are then copied to /opt/ibm. Finally

chown -R root:root /opt/ibm/cobol

3. Prerequisites. Installation guide specifies that the compiler needs 32-bit libraries. Without 32-bit libraries you will get below error when calling cob2:

cob3: execve() failed:  rc -1  errno 2 No such file or directory

cob2 is the actual compiler call and is a 64-bit application which in turn calls cob3, the 32-bit binary.

On Arch Linux the cure is to install lib32-gcc-libs:

pacman -S lib32-gcc-libs

Before that you have to activate multilib in /etc/pacman.conf:

Include = /etc/pacman.d/mirrorlist

With the 32-bit libraries installed, you can check cob3:

/opt/ibm/cobol/1.1.0/bin: ldd cob3
        linux-gate.so.1 (0xf7f2b000)
        libcob2_32r.so => /opt/ibm/cobol/1.1.0/usr/bin/./../../../rte/usr/lib/libcob2_32r.so (0xf7e30000)
        libdfp_32r.so => /opt/ibm/cobol/1.1.0/usr/bin/./../../../rte/usr/lib/libdfp_32r.so (0xf7d9b000)
        libquadmath.so.0 => /usr/lib32/libquadmath.so.0 (0xf7cff000)
        libdl.so.2 => /usr/lib32/libdl.so.2 (0xf7cf9000)
        libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf7ae8000)
        libm.so.6 => /usr/lib32/libm.so.6 (0xf7a1b000)
        libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf79fd000)
        libpthread.so.0 => /usr/lib32/libpthread.so.0 (0xf79db000)
        libc.so.6 => /usr/lib32/libc.so.6 (0xf77e2000)
        libicuuc_32r.so => /opt/ibm/cobol/1.1.0/usr/bin/./../../../rte/usr/lib/libicuuc_32r.so (0xf75f4000)
        libicui18n_32r.so => /opt/ibm/cobol/1.1.0/usr/bin/./../../../rte/usr/lib/libicui18n_32r.so (0xf72da000)
        /lib/ld-linux.so.2 => /usr/lib/ld-linux.so.2 (0xf7f2d000)
        libicudata_32r.so => /opt/ibm/cobol/1.1.0/usr/bin/./../../../rte/usr/lib/libicudata_32r.so (0xf5897000)

The compiler is a 32-bit application and can currently only generate 32-bit executables. In particular, you can not use 64-bit pointer variables. See also Memory Limitations with IBM Enterprise COBOL Compiler. Man page, man -l /opt/ibm/cobol/1.1.0/man/man1/cob2.1, confirms this:

-q32   Specifies that a 32-bit object program is to be generated.  Sets the ADDR(32) compiler option and the  linker  option  to
       instruct the linker to create a 32-bit executable module.

-q64   This option is not currently supported. The compiler accepts and ignores this option.

4. Testing the installation. Running the compiler goes like this:

cob2 hello.cbl

This will generate the usual a.out.

Overall the installation needs ca. 160 MB of hard disk storage:

$ du -ks /opt/ibm/cobol
158860  /opt/ibm/cobol

5. Documentation. IBM provides ample documentation for its Linux COBOL compiler: COBOL for Linux on x86 documentation library.

Categories: Linux
Tags: COBOL, IBM, cob2, cob3
Author: Elmar Klausmeier