Skip to main content

Problem:

You may get the "undefined reference" error message when compiling and linking a program with cob that contains a call to another program and this second program is not included in the cob command line to be included in the resulting executable.

For example, if inside mainprog.cbl there is a call to a program prog2.cbl:

    call "prog2" using ...

the following command

    cob -x mainprog.cbl

will return an "undefined reference" error message on the symbol "prog2".

Resolution:

Assuming that you have already compiled prog2.cbl independently because you want it to be loaded dynamically at run time when you run mainprog as a shared object:

   cob -z prog2.cbl

or as .int code:

   cob -i prog2.cbl

or as .gnt code:

   cob -u prog2.cbl

(please have a look to your User's Guide manual to understand the differences and how the environment has to be set up so the run time can dynamically find and load prog2.so or prog2.int or prog2.gnt).

Then, when you compile mainprog.cbl, one of two, or you tell the linker to ignore any undefined reference because you are going to load them all dynamically at runtime, or you tell the linker where to find the particular undefined reference.

To tell the linker to ignore any undefined reference use the -U cob flag:

   cob -xU mainprog.cbl

For more information please look at the User's Guide Manual, cob flags chapter.

Old KB# 7286