本人装的是Version 11.2.0.4.0 ,所以一下都是以Version 11.2.0.4.0 为例子,系统是CentOS 7.3
1、https://www.coder4.com/archives/1453
1、首先下载好必备的包
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
instantclient-basic-linux.x64-11.2.0.4.0.zip (这个我用到了,这个和下面的是一样的,应该不用也可以,由于下面要用到这个解压出来的文件,所以就没去另外琢磨了。)
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
2、
安装alien
yum -y install alien (非root请加权限,下同)
将rmp转为deb
alien ./oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
alien ./oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
安装转换完的deb,如没有dpkg,请自行安装
dpkg -i ./oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.deb
dpkg -i ./oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.deb
我安装好的位置分别在(文件夹名可能不同)
/usr/lib/oracle/11.2/client64/lib
/usr/include/oracle/11.2/client64
3、设置环境变量(我的是zsh,关于ohmyzsh下一篇写,注意不要乱复制看好自己的路径)
vim
~
/
.
zshrc(如果是bash就是bashrc了)
export
LD_LIBRARY_PATH
=
$
LD_LIBRARY_PATH
:
/
usr
/
lib
/
oracle
/
11.2
/
client64
/
lib
4、安装配置OCI(根据自己的自行修改)
./configure --with-oracle-lib-path=/usr/lib/oracle/11.2/client64/lib --with-oracle-headers-path=/usr/include/oracle/11.2/client64
make
make install
5、之后编译自己的代码是出现的错误(类似的错误,也可以试试这个解决方法)
①/usr/bin/ld: warning: libclntsh.so.11.1, needed by /usr/local/lib/libocilib.so, not found (try using -rpath or -rpath-link)
/usr/local/lib/libocilib.so: undefined reference to `OCILobTrim2'
/usr/local/lib/libocilib.so: undefined reference to `OCILobIsEqual'
/usr/local/lib/libocilib.so: undefined reference to `OCILobGetChunkSize'
/usr/local/lib/libocilib.so: undefined reference to `OCIRawSize'
/usr/local/lib/libocilib.so: undefined reference to `OCIDirPathColArrayReset'
/usr/local/lib/libocilib.so: undefined reference to `OCIThreadIdInit'
/usr/local/lib/libocilib.so: undefined reference to `OCIDateTimeSubtract'
/usr/local/lib/libocilib.so: undefined reference to `OCITypeByRef'
/usr/local/lib/libocilib.so: undefined reference to `OCILobWriteAppend2'
/usr/local/lib/libocilib.so: undefined reference to `OCIThreadProcessInit'
/usr/local/lib/libocilib.so: undefined reference to `OCIServerVersion'
/usr/local/lib/libocilib.so: undefined reference to `OCIIterDelete'
/usr/local/lib/libocilib.so: undefined reference to `OCIStmtGetPieceInfo'
/usr/local/lib/libocilib.so: undefined reference to `OCICollAppend'
/usr/local/lib/libocilib.so: undefined reference to `OCIAttrSet'
/usr/local/lib/libocilib.so: undefined reference to `OCIPasswordChange'
/usr/local/lib/libocilib.so: undefined reference to `OCIIntervalGetDaySecond'
/usr/local/lib/libocilib.so: undefined reference to `OCILobOpen'
/usr/local/lib/libocilib.so: undefined reference to `OCILobClose'
/usr/local/lib/libocilib.so: undefined reference to `OCIStmtFetch'
/usr/local/lib/libocilib.so: undefined reference to `OCIBindDynamic'
/usr/local/lib/libocilib.so: undefined reference to `OCIDescriptorAlloc'
/usr/local/lib/libocilib.so: undefined reference to `OCILobLoadFromFile2'
在/etc/ld.so.conf中添加 /home/oracle/cry/instantclient_11_2 后正常.(instantclient_11_2 这个文件就是上面的zip解压出来的)
②
./tests: error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or directory
出现这类错误表示,系统不知道
xxx.so
放在哪个目录下,这时候就要在/etc/
ld.so.conf中加入xxx.so所在的目录。
一般而言,有很多的so会存放在/usr/local/lib这个目录底下,去这个目录底下找,果然发现自己所需要的.so文件。
所以,在/etc/ld.so.conf中加入/usr/local/lib这一行,保存之后,再运行:/sbin/ldconfig –v更新一下配置即可。
以上整合修改自这四个地方,稍有修改,我无耻的加了原创,哈哈哈
https://www.coder4.com/archives/1453
http://blog.csdn.net/zklth/article/details/7184032
http://blog.csdn.net/edcvf3/article/details/9430637
http://blog.csdn.net/dumeifang/article/details/2963223
如发现问题可以相互讨论,谢谢!