1、在http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html下载所需要的oracle instant client
2、本人操作系统版本为ubuntu,所以需要执行以下步骤才可以安装
tpc-pds-2@tpcpds2-Lenovo:~/install$ sudo apt-get install alien
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-2.6.38-8-generic linux-headers-2.6.38-8
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
debhelper html2text libmail-sendmail-perl librpm1 librpmbuild1 librpmio1 libsys-hostname-long-perl po-debconf rpm rpm-common
rpm2cpio
Suggested packages:
lsb-rpm dh-make libmail-box-perl elfutils rpm-i18n
The following NEW packages will be installed:
alien debhelper html2text libmail-sendmail-perl librpm1 librpmbuild1 librpmio1 libsys-hostname-long-perl po-debconf rpm
rpm-common rpm2cpio
0 upgraded, 12 newly installed, 0 to remove and 9 not upgraded.
Need to get 904 kB/1445 kB of archives.
After this operation, 4784 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ natty/main html2text amd64 1.3.2a-15 [104 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu/ natty/main po-debconf all 1.0.16+nmu1 [212 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu/ natty/main debhelper all 8.1.2ubuntu4 [482 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu/ natty/main librpmio1 amd64 4.8.1-6ubuntu1 [84.8 kB]
Get:5 http://cn.archive.ubuntu.com/ubuntu/ natty/main librpmio1 amd64 4.8.1-6ubuntu1 [84.8 kB]
Get:6 http://cn.archive.ubuntu.com/ubuntu/ natty/main rpm-common amd64 4.8.1-6ubuntu1 [21.3 kB]
Fetched 860 kB in 6min 47s (2110 B/s)
Selecting previously deselected package html2text.
(Reading database ... 171360 files and directories currently installed.)
Unpacking html2text (from .../html2text_1.3.2a-15_amd64.deb) ...
Selecting previously deselected package po-debconf.
Unpacking po-debconf (from .../po-debconf_1.0.16+nmu1_all.deb) ...
Selecting previously deselected package debhelper.
Unpacking debhelper (from .../debhelper_8.1.2ubuntu4_all.deb) ...
Selecting previously deselected package librpmio1.
Unpacking librpmio1 (from .../librpmio1_4.8.1-6ubuntu1_amd64.deb) ...
Selecting previously deselected package rpm-common.
Unpacking rpm-common (from .../rpm-common_4.8.1-6ubuntu1_amd64.deb) ...
Selecting previously deselected package librpm1.
Unpacking librpm1 (from .../librpm1_4.8.1-6ubuntu1_amd64.deb) ...
Selecting previously deselected package librpmbuild1.
Unpacking librpmbuild1 (from .../librpmbuild1_4.8.1-6ubuntu1_amd64.deb) ...
Selecting previously deselected package rpm2cpio.
Unpacking rpm2cpio (from .../rpm2cpio_4.8.1-6ubuntu1_amd64.deb) ...
Selecting previously deselected package rpm.
Unpacking rpm (from .../rpm_4.8.1-6ubuntu1_amd64.deb) ...
Selecting previously deselected package alien.
Unpacking alien (from .../archives/alien_8.83_all.deb) ...
Selecting previously deselected package libsys-hostname-long-perl.
Unpacking libsys-hostname-long-perl (from .../libsys-hostname-long-perl_1.4-2_all.deb) ...
Selecting previously deselected package libmail-sendmail-perl.
Unpacking libmail-sendmail-perl (from .../libmail-sendmail-perl_0.79.16-1_all.deb) ...
Processing triggers for man-db ...
Processing triggers for doc-base ...
Processing 1 added doc-base file(s)...
Registering documents with scrollkeeper...
Setting up html2text (1.3.2a-15) ...
Setting up po-debconf (1.0.16+nmu1) ...
Setting up debhelper (8.1.2ubuntu4) ...
Setting up librpmio1 (4.8.1-6ubuntu1) ...
Setting up rpm-common (4.8.1-6ubuntu1) ...
Setting up librpm1 (4.8.1-6ubuntu1) ...
Setting up librpmbuild1 (4.8.1-6ubuntu1) ...
Setting up rpm2cpio (4.8.1-6ubuntu1) ...
Setting up rpm (4.8.1-6ubuntu1) ...
Setting up alien (8.83) ...
Setting up libsys-hostname-long-perl (1.4-2) ...
Setting up libmail-sendmail-perl (0.79.16-1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
tpc-pds-2@tpcpds2-Lenovo:~/install$ ls -l
total 58344
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 58296106 Jul 26 20:21 oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 608014 Jul 26 20:10 oracle-instantclient11.2-devel-11.2.0.2.0.x86_64.rpm
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 831327 Jul 26 20:11 oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm
tpc-pds-2@tpcpds2-Lenovo:~/install$ sudo alien oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
oracle-instantclient11.2-basic_11.2.0.2.0-2_amd64.deb generated
tpc-pds-2@tpcpds2-Lenovo:~/install$ sudo alien oracle-instantclient11.2-devel-11.2.0.2.0.x86_64.rpm
oracle-instantclient11.2-devel_11.2.0.2.0-2_amd64.deb generated
tpc-pds-2@tpcpds2-Lenovo:~/install$ sudo alien oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm oracle-instantclient11.2-sqlplus_11.2.0.2.0-2_amd64.deb generated
3、安装oracle包
tpc-pds-2@tpcpds2-Lenovo:~/install$ sudo dpkg -i oracle-instantclient11.2-basic_11.2.0.2.0-2_amd64.deb oracle-instantclient11.2-devel_11.2.0.2.0-2_amd64.deb oracle-instantclient11.2-sqlplus_11.2.0.2.0-2_amd64.deb
Selecting previously deselected package oracle-instantclient11.2-basic.
(Reading database ... 171928 files and directories currently installed.)
Unpacking oracle-instantclient11.2-basic (from oracle-instantclient11.2-basic_11.2.0.2.0-2_amd64.deb) ...
Selecting previously deselected package oracle-instantclient11.2-devel.
Unpacking oracle-instantclient11.2-devel (from oracle-instantclient11.2-devel_11.2.0.2.0-2_amd64.deb) ...
Selecting previously deselected package oracle-instantclient11.2-sqlplus.
Unpacking oracle-instantclient11.2-sqlplus (from oracle-instantclient11.2-sqlplus_11.2.0.2.0-2_amd64.deb) ...
Setting up oracle-instantclient11.2-basic (11.2.0.2.0-2) ...
Setting up oracle-instantclient11.2-devel (11.2.0.2.0-2) ...
Setting up oracle-instantclient11.2-sqlplus (11.2.0.2.0-2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
tpc-pds-2@tpcpds2-Lenovo:~/install$ cd /usr/lib/oracle
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle$ dir
11.2
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle$ cd 11.2
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2$ dir
client64
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2$ cd client64/
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64$ dir
bin lib
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64$ cd lib
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/lib$ ls -l
total 181492
-rw-r--r-- 1 root root 342 Sep 5 2010 glogin.sql
lrwxrwxrwx 1 root root 17 Jul 27 11:11 libclntsh.so -> libclntsh.so.11.1
-rw-r--r-- 1 root root 52439406 Sep 5 2010 libclntsh.so.11.1
-rw-r--r-- 1 root root 7898628 Sep 5 2010 libnnz11.so
lrwxrwxrwx 1 root root 15 Jul 27 11:11 libocci.so -> libocci.so.11.1
-rw-r--r-- 1 root root 1972824 Sep 5 2010 libocci.so.11.1
-rw-r--r-- 1 root root 115820762 Sep 5 2010 libociei.so
-rw-r--r-- 1 root root 164756 Sep 5 2010 libocijdbc11.so
-rw-r--r-- 1 root root 1471902 Sep 5 2010 libsqlplus.so
-rw-r--r-- 1 root root 1503279 Sep 5 2010 libsqlplusic.so
-rw-r--r-- 1 root root 2030135 Sep 5 2010 ojdbc5.jar
-rw-r--r-- 1 root root 2152051 Sep 5 2010 ojdbc6.jar
-rw-r--r-- 1 root root 298394 Sep 5 2010 ottclasses.zip
-rw-r--r-- 1 root root 66783 Sep 5 2010 xstreams.jar
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/lib$ pwd
/usr/lib/oracle/11.2/client64/lib
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/lib$ cd ..
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64$ dir
bin lib
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64$ cd bin
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/bin$ dir
adrci genezi sqlplus
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/bin$ ls -l
total 48
-rwxr-xr-x 1 root root 8136 Sep 5 2010 adrci
-rwxr-xr-x 1 root root 30384 Sep 5 2010 genezi
-rwxr-xr-x 1 root root 4920 Sep 5 2010 sqlplus
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/bin$ pwd
/usr/lib/oracle/11.2/client64/bin
4、配置环境变量
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64$ cd ~
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64$ vi .bashrc
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
".bashrc" 106 lines, 3494 characters written
tpc-pds-2@tpcpds2-Lenovo:~$
oracle oci lib安装位置:/usr/lib/oracle/11.2/client64/lib
编译oci驱动要用的.h文件安装位置:/usr/include/oracle/11.2/client64/
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/lib$ cd /usr/include/oracle/11.2/client64/
tpc-pds-2@tpcpds2-Lenovo:/usr/include/oracle/11.2/client64$ ls
ldap.h occi.h occiControl.h oci.h ociap.h ocidem.h ocikpr.h odci.h orid.h ort.h
nzerror.h occiAQ.h occiData.h oci1.h ociapr.h ocidfn.h ocixmldb.h oratypes.h orl.h xa.h
nzt.h occiCommon.h occiObjects.h oci8dp.h ocidef.h ociextp.h ocixstream.h ori.h oro.h
tpc-pds-2@tpcpds2-Lenovo:/usr/include/oracle/11.2/client64$ cd ..
tpc-pds-2@tpcpds2-Lenovo:/usr/include/oracle/11.2$ cd /usr/lib/oracle/11.2/client64/lib
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/lib$ ls -l
total 181492
-rw-r--r-- 1 root root 342 Sep 5 2010 glogin.sql
lrwxrwxrwx 1 root root 17 Jul 27 11:11 libclntsh.so -> libclntsh.so.11.1
-rw-r--r-- 1 root root 52439406 Sep 5 2010 libclntsh.so.11.1
-rw-r--r-- 1 root root 7898628 Sep 5 2010 libnnz11.so
lrwxrwxrwx 1 root root 15 Jul 27 11:11 libocci.so -> libocci.so.11.1
-rw-r--r-- 1 root root 1972824 Sep 5 2010 libocci.so.11.1
-rw-r--r-- 1 root root 115820762 Sep 5 2010 libociei.so
-rw-r--r-- 1 root root 164756 Sep 5 2010 libocijdbc11.so
-rw-r--r-- 1 root root 1471902 Sep 5 2010 libsqlplus.so
-rw-r--r-- 1 root root 1503279 Sep 5 2010 libsqlplusic.so
-rw-r--r-- 1 root root 2030135 Sep 5 2010 ojdbc5.jar
-rw-r--r-- 1 root root 2152051 Sep 5 2010 ojdbc6.jar
-rw-r--r-- 1 root root 298394 Sep 5 2010 ottclasses.zip
-rw-r--r-- 1 root root 66783 Sep 5 2010 xstreams.jar
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64/lib$ cd ..
tpc-pds-2@tpcpds2-Lenovo:/usr/lib/oracle/11.2/client64$ ls
bin lib network
5.编译QOCI驱动
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci$ cd /home/tpc-pds-2/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci$ ls
Makefile README main.cpp main.o moc_qsql_oci.cpp moc_qsql_oci.o oci.pro qsql_oci.o
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci$ ls -l
total 240
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 9225 Aug 11 17:38 Makefile
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 205 Sep 10 2010 README
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 2774 Sep 10 2010 main.cpp
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 13512 Aug 11 17:38 main.o
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 2081 Aug 11 17:38 moc_qsql_oci.cpp
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 6456 Aug 11 17:38 moc_qsql_oci.o
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 289 Sep 10 2010 oci.pro
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 192320 Aug 11 17:24 qsql_oci.o
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci$ rm -fr main.o moc_* qsql_oci.o Makefile
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci$ ls -l
total 12
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 205 Sep 10 2010 README
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 2774 Sep 10 2010 main.cpp
-rw-r--r-- 1 tpc-pds-2 tpc-pds-2 289 Sep 10 2010 oci.pro
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci$ qmake "INCLUDEPATH+=/usr/include/oracle/11.2/client64/" "LIBS+=-L/usr/lib/oracle/11.2/client64/lib -lclntsh" oci.pro
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci$ make
g++ -c -m64 -pipe -O2 -fvisibility=hidden -fvisibility-inlines-hidden -D_REENTRANT -Wall -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../mkspecs/linux-g++-64 -I. -I../../../../include/QtCore -I../../../../include/QtSql -I../../../../include -I/usr/include/oracle/11.2/client64 -I. -o main.o main.cpp
g++ -c -m64 -pipe -O2 -fvisibility=hidden -fvisibility-inlines-hidden -D_REENTRANT -Wall -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../mkspecs/linux-g++-64 -I. -I../../../../include/QtCore -I../../../../include/QtSql -I../../../../include -I/usr/include/oracle/11.2/client64 -I. -o qsql_oci.o ../../../sql/drivers/oci/qsql_oci.cpp
/home/tpc-pds-2/qtsdk-2010.05/qt/bin/moc -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../mkspecs/linux-g++-64 -I. -I../../../../include/QtCore -I../../../../include/QtSql -I../../../../include -I/usr/include/oracle/11.2/client64 -I. ../../../sql/drivers/oci/qsql_oci.h -o moc_qsql_oci.cpp
g++ -c -m64 -pipe -O2 -fvisibility=hidden -fvisibility-inlines-hidden -D_REENTRANT -Wall -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../mkspecs/linux-g++-64 -I. -I../../../../include/QtCore -I../../../../include/QtSql -I../../../../include -I/usr/include/oracle/11.2/client64 -I. -o moc_qsql_oci.o moc_qsql_oci.cpp
rm -f libqsqloci.so
g++ -m64 -Wl,-O1 -Wl,-rpath,/home/tpc-pds-2/qtsdk-2010.05/qt/lib -shared -o libqsqloci.so main.o qsql_oci.o moc_qsql_oci.o -L/home/tpc-pds-2/qtsdk-2010.05/qt/lib -L/usr/lib/oracle/11.2/client64/lib -lclntsh -lQtSql -L/home/tpc-pds-2/qtsdk-2010.05/qt/lib -lQtCore -lpthread
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/src/plugins/sqldrivers/oci$ make install
install -m 755 -p "libqsqloci.so" "/home/tpc-pds-2/qtsdk-2010.05/qt/plugins/sqldrivers/libqsqloci.so"
strip --strip-unneeded "/home/tpc-pds-2/qtsdk-2010.05/qt/plugins/sqldrivers/libqsqloci.so"
tpc-pds-2@tpcpds2-Lenovo:~$ cd /home/tpc-pds-2/qtsdk-2010.05/qt/plugins/sqldrivers/
tpc-pds-2@tpcpds2-Lenovo:~/qtsdk-2010.05/qt/plugins/sqldrivers$ ls -lt
total 49168
-rwxr-xr-x 1 tpc-pds-2 tpc-pds-2 118416 Aug 12 09:09 libqsqloci.so
-rwxr-xr-x 1 tpc-pds-2 tpc-pds-2 2071528 Sep 29 2010 libqsqlite.so
-rwxr-xr-x 1 tpc-pds-2 tpc-pds-2 460005 Sep 29 2010 libqsqlite2.so
-rwxr-xr-x 1 tpc-pds-2 tpc-pds-2 611781 Sep 29 2010 libqsqlpsql.so