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 variablesOBJECT_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
(prefix 옵션을 생략하면 /usr/local 디렉토리를 사용한다)
- 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]/bindirectory. - 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: (명령을 수행하기 전에 OBJECT_MODE 환경변수가 설정되어 있는지 확인한다)
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. (파일확장자는 unixODBC 버전에 따라 달라질 수 있다) - 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.
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.cli.doc/doc/t0010406.html