Created On:  17 November 2010

Problem:

Compiling or Executing a DB2 application fails with RTS198 (load failure) against cobsqlecm or cobsqlecm64
Compiling a DB2 application returns 801-S sqlecm or dependant module not found error
Compiling a DB2 application rejects all DB2(x) directives
Linking a DB2 application gives a "bad magic number" error
Linking a DB2 application on UNIX returns undefined symbol errors against sqlgstrt, sqlgaloc, sqlgstlv, sqlgcall sqlgstop sqlgintp, and cobdb2

Resolution:

In order to compile and execute an application which has been precompiled using IBM's DB2 precompiler, i.e. if you have either :

* Compiled your host program with the DB2 compiler directive, or
* Precompiled your host program with the DB2 command line precompiler, db2 prep, and
   compiled the resultant output

then you need to have the DB2 environment set up correctly. On some UNIX platforms, you will also need to ensure that the COBOL working mode matches the type of DB2 instance you are using, i.e. 32-bit or 64-bit.

You should invoke "cobmode" to determine your current COBOL working mode.

If you're not logged in under the UNIX account for the DB2 instance ID, the easiest way to set up the DB2 environment is to use the profile script created by IBM's instance-creation process. Under bourne shell (or Korn shell/bash), use :

. ~[db2_instance_id]/sqllib/db2profile
export DB2DIR

e.g.

. ~db2inst1/sqllib/db2profile
export DB2DIR

To determine whether the DB2 instance is 32-bit or 64-bit, you should execute the (IBM) 'db2level' command, which will return something like :

DB21085I  Instance "db82inst" uses "32" bits and DB2 code release "SQL08021"
 with level identifier "03020106".
 Informational tokens are "DB2 v8.1.0.80", "s041221", "U800664", and FixPak "8".
 Product is installed at "/opt/IBM/db2/V8.1".

for a 32-bit instance, or

 DB21085I  Instance "db8264in" uses "64" bits and DB2 code release "SQL08021"
 with level identifier "03020106".
 Informational tokens are "DB2 v8.1.0.80", "s041221", "U800664", and FixPak "8".
 Product is installed at "/opt/IBM/db2/V8.1".

for a 64-bit instance.

Note the use of '.... uses "nn" bits' in the output.

Refer to the Server Express Database Access Manual, within the DB2 chapter for details on how to link applications compiled with the DB2 compiler directive. For DB2 applications which have been separately precompiled using IBM's command-line precompiler, db2 prep, refer to IBM documentation for how to link the application.