IBM Support

"The module has an invalid magic number." when trying to use DB2's ODBC driver on AIX

Troubleshooting


Problem

When using an ODBC driver manager with DB2's ODBC driver on AIX, the application might fail with the following error: 0509-103 The module has an invalid magic number.

Cause

The DB2 ODBC library on AIX is an archived library called libdb2.a. Some ODBC driver managers load ODBC drivers dynamically and cannot work with archived libraries. They may therefore fail when trying to load the DB2 ODBC library on AIX from the ODBC driver manager.

For example, the unixODBC driver manager cannot use an archived library.

Resolving The Problem

If this error occurs, you will want to ensure that you are linking the ODBC driver manager with a shared library as opposed to an archived library.

The DB2 ODBC library on AIX in DB2 v9.1 and greater is a hybrid library. This means that this library contains both 32-bit and 64-bit elements.

To generate a 32-bit shared library from the DB2 ODBC library on AIX, you will want to issue the following commands:


cd INSTHOME/sqllib/lib
ar -x libdb2.a
mv shr.o db2.o

where INSTHOME is the home directory of the instance owner.

To generate a 64-bit shared library from the DB2 ODBC library on AIX, you will want to issue the following commands:


cd INSTHOME/sqllib/lib
ar -x -X 64 libdb2.a
mv shr_64.o db2_64.o

where INSTHOME is the home directory of the instance owner.


You will then need to modify the ODBC driver manager's configuration file (usually odbcinst.ini) to point to the new shared library (db2.o for 32-bit, or db2_64.o for 64-bit), instead of the archived library (libdb2.a).

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Programming Interface - ODBC","Platform":[{"code":"PF002","label":"AIX"}],"Version":"9.7;9.5;9.1","Edition":"Enterprise Server;Express;Personal;Personal Developer's;Workgroup Server","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21422729