DB2 10.5 for Linux, UNIX, and Windows

Compiling the unixODBC driver manager

You can compile the unixODBC Driver Manager on Linux or UNIX operating systems for use with CLI and ODBC applications.

Procedure

To compile the unixODBC Driver Manager:

  1. Download the latest unixODBC source code from http://www.unixodbc.org.
  2. Untar the source files. For example:
    gzip -d unixODBC-2.2.11.tar.gz
    tar xf unixODBC-2.2.11.tar
  3. For AIX® only: Configure the C compiler to be thread-enabled:
    export CC=xlc_r
    export CCC=xlC_r
  4. To compile a 64-bit version of the driver manager with the xlc_r compilers, set the environment variables OBJECT_MODE and CFLAGS:
    export OBJECT_MODE=64
    export CFLAGS=-q64 -DBUILD_REAL_64_BIT_MODE
  5. Install the driver manager in either your home directory or the default /usr/local prefix:
    • (Home directory) Issue the following command in the directory where you untarred the source files:
      ./configure --prefix=$HOME -DBUILD_REAL_64_BIT_MODE --enable-gui=no 
                                         --enable-drivers=no
    • (/usr/local as root) Issue the following command:
      ./configure --enable-gui=no --enable-drivers=no
  6. Optional: Examine all configuration options by issuing the following command:
    ./configure --help
  7. Build and install the driver manager:
    make
    make install
    Libraries are copied to the [prefix]/lib directory, and executable files are copied to the [prefix]/bin directory.
  8. For AIX only: Extract the shared library from the ODBC driver for DB2® to yield shr.o on 32-bit operating systems and shr_64.o on 64-bit operating systems. To avoid confusion, rename the files db2.o and db2_64.o. These steps are necessary on AIX because the unixODBC Driver Manager loads the driver dynamically.
    • On 32-bit operating systems, 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.
    • On 64-bit operating systems, 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.
    Ensure that your INI file references the correct library.
  9. Optional: For AIX only: Extract libodbc.a, libodbcinst.a, and libodbccr.a if you are dynamically loading the driver manager:
    ar -x libodbc.a
    ar -x libodbcinst.a
    ar -x libodbccr.a 
    The ar commands in previous example produce libodbc.so.1, libodbcinst.so.1, and libodbccr.so.1 in the [prefix]/lib/so directory.
  10. Build the application and ensure that it is linked to the unixODBC Driver Manager by including the -L[prefix]/lib -lodbc option in the compile and link command.
  11. Specify the paths for at least the user INI file (odbc.ini) or the system INI file (odbcinst.ini), and set the ODBCHOME environment variable to the directory where the system INI file was created.
    Important: Provide absolute paths when you are specifying the paths of the user and system INI files. Do not use relative paths or environment variables.
    Note: If you are compiling 64-bit applications for the ODBC Driver, use the -DODBC64 option to enable the 64-bit definitions in the driver manager.