To run ODBC applications on Linux or UNIX operating
systems, you must configure the unixODBC Driver Manager.
Procedure
To set up the unixODBC Driver Manager for use with CLI and
ODBC applications:
- Download the latest unixODBC source code from http://www.unixodbc.org.
- Untar the source files. For example:
gzip -d unixODBC-2.2.11.tar.gz
tar xf unixODBC-2.2.11.tar
- For AIX® only: Configure
the C compiler to be thread-enabled:
export CC=xlc_r
export CCC=xlC_r
- To compile a 64-bit version of the driver manager using
the xlc_r compilers, set the environment variables OBJECT_MODE and CFLAGS:
export OBJECT_MODE=64
export CFLAGS=-q64 -DBUILD_REAL_64_BIT_MODE
- Install the driver manager in either your home directory
or the default /usr/local prefix:
- Optional: Examine all configuration options
by issuing the following command:
./configure --help
- Build and install the driver manager:
make
make install
Libraries will be copied to
the [prefix]/lib directory, and executables will
be copied to the [prefix]/bin directory.
- 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,
respectively. These steps are necessary on AIX because the unixODBC Driver Manager loads
the driver dynamically.
Ensure that your INI file references the correct library.
- Optional: For AIX only: Extract libodbc.a, libodbcinst.a,
and libodbccr.a if you will be dynamically loading
the driver manager:
ar -x libodbc.a
ar -x libodbcinst.a
ar -x libodbccr.a
This produces libodbc.so.1, libodbcinst.so.1,
and libodbccr.so.1 respectively in the [prefix]/lib/so directory.
- Build the application and ensure it is linked to the unixODBC
Driver Manager by including the -L[prefix]/lib -lodbc
option in the compile and link command.
- 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 specifying
the paths of the user and system INI files. Do not use relative paths
or environment variables.
Note: If
compiling 64-bit applications for the ODBC Driver, use the -DODBC64 option
to enable the 64-bit definitions in the driver manager.