GCC Linux DB2 COBOL compiler option issues

Compiling/Linking COBOL code on a RHEL 8.6, which compiles fine but then when it tries to link I get an error with one of the variables: cob2 -F//etc/cob2.cfg -v <cobolprog.cbl> -L/lib64 -ldb2 -I/include/cobol_a/ -q"size(16384K) -o cobolprog

The output is /usr/bin/ld: skipping incompatible lib64/ when searching for -ldb2 /usr/bin/ld: cannot find -ldb2 If I remove the -ldb2 I get 'undefined reference to 'SQLGSTRT', 'SQLGALOC etc

When I try this with lib32 and -ldb2 I dont see issues?

I did try using the -q64 on the cmd line but apparently this is not supported on linux.

db2level Informational tokens are "DB2 v11.5.0.0", "s1906101300", "DYN1906101300AMD64", and Fix Pack "0". Product is installed at "/opt/IBM/db2/V11.5"

cob2 -V Program cob2 Version 1.1.0 Built Mon Sep 27 10:39:30 2021

Tried 32 bit which compiles the cobol fine, but it now seems to have an issue with linking a static library I need: /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib/Scrtl.0(.text+0x1c): unresolvable R_386_GOTOFF relocation against symbol '__libc_csu_fini'


  • It appears that you are using IBM COBOL for Linux on x86 version 1.1.

    According to IBM's documentation at this link the ADDR compiler option specifies whether to create a 32-bit or 64-bit object file.

    Additionally, as you are on version 1.1 (the currently available version as of February-2023), the documentation also has this specific relevant note:

    Note: The ADDR(64) and -q64 options are not currently supported. The compiler accepts and ignores these options and defaults to ADDR(32).

    This means that your object file is 32-bit, but you are trying to link (ld) with the 64-bit Db2 libraries, and consequently ld skips the incomptabile library with the message that you see. You should Link with the 32-bit Db2 libraries instead, they are in the lib32 directory of the Db2 client, so arrange for this in your command line options.