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:
- 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 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
- 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
- (Home directory) Issue the following command in the directory
where you untarred the source files:
- Optional: Examine all configuration options
by issuing the following command:
./configure --help
- 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. -
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:
where INSTHOME is the home directory of the instance owner.cd INSTHOME/sqllib/lib ar -x libdb2.a mv shr.o db2.o
- On 64-bit operating systems, issue the following
commands:
where INSTHOME is the home directory of the instance owner.cd INSTHOME/sqllib/lib ar -x -X 64 libdb2.a mv shr_64.o db2_64.o
Ensure that your INI file references the correct library. - On 32-bit operating systems, issue the following
commands:
- 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. - 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. - 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.