Linux 编译安装OciLib 4.x.x

项目要用oracle , Windows的 OciLib 好弄, 今天安装到linux下 ,编译老是出错,最后几行如下:

checking for OCILIB install path... /usr/local
ls: cannot access *.html: No such file or directory
ls: cannot access *.css: No such file or directory
ls: cannot access *.png: No such file or directory
checking for OCILIB version... v4.2.1 
checking for OCILIB options... import: linkage, charset = ansi 
checking for Oracle home... defined by environment : 
checking for Oracle OCI headers location... configure: error: variable not set or unable to guess

然后搜索 configure文件,最终发现是 oracle oci 的头文件的文件夹没找到;

然后到oracle官网下载 instantclient-sdk-linux 又是一阵折腾,不知道他抽什么疯,死活不能下载, 下载页点击跳转就到错误页了~~~

后来网上找了个下载,还好,能用(文件大小只有625KB), 地址:http://download.csdn.net/detail/lsxy117/5118691

-------------------更新---------------- 2020/07/01

instantclient 在这里下载: (需要注册,注册下就好了:)

https://www.oracle.com/database/technologies/instant-client/downloads.html

-----------------------------------------

但是下载解压后 configure 文件里的路径居然没有include文件夹的配置,尼玛,自己写了(约第12775行处):

      # find out the Oracle public OCI headers path
      if test "$ac_headers_path" = NO; then
        if test "$ac_oracle_home" != NO; then
          test_include_path=$ac_oracle_home/rdbms/public
          if test -d "$test_include_path"; then
            ac_headers_path=$test_include_path
          else
            test_include_path=$ac_oracle_home/rdbms/demo
            if test -d "$test_include_path"; then
              ac_headers_path=$test_include_path
            else
              echo "line 12775 ,lzpong add this ac_headers_path to $ac_oracle_home/include , need to download instantclient-sdk-linux-xx.xx.xx.zip to get includes file!!!!"
              ac_headers_path=$ac_oracle_home/include
            fi
          fi
        fi
      fi

因为我是直接把sdk的include文件夹解压到 /usr/local/instantclient_12_1 的,所以 直接写了:

ac_headers_path=$ac_oracle_home/include

-------------------更新---------------- 2020/07/01

可以不用改`makefile`,直接参数指定

./configure  CFLAGS="-O2 -m64" --with-oracle-lib-path=/usr/local/instantclient_12_1 --with-oracle-headers-path=/usr/local/instantclient_12_1/include

CFLAGS 参数很重要, -m64 表示编译为64位。

--with-oracle-lib-path 参数指定 lib 目录

--with-oracle-headers-path 参数指定 头文件目录

这样就应该不需要设置环境变量了, 不行在按下方设置咯~~

-----------------------------------------

然后要配置 环境变量的!!!

根据这里(http://ljhzzyx.blog.163.com/blog/static/3838031220107139322436/)配置了,没重新登录 没起作用, 于是直接执行了下:

export ORACLE_HOME=/usr/local/instantclient_12_1

export PATH=$ORACLE_HOME:$PATH

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME

export TNS_ADMIN=$ORACLE_HOME/network/admin

export NLS_LANG="Simplified Chinese_china".ZHS16GBK

./configure

make

make install

 

至此, 已经安装好了 ^_^, 没有出错哦,

lib文件在 /usr/local/lib

头文件在 /usr/local/include

好了,可以使用 OciLib 4.2.1 了 ;

 

也可以查看他的 readme 文件, 可以搭配一些参数make install

Website : http://www.ocilib.net

GitHub : https://github.com/vrogier/ocilib

 

PS:不过这个库貌似默认是编译的 32位的, 如如何编译64位的, 看上面更新说明的CFLAGS参数。, 谢谢!

 

posted @ 2016-08-12 12:14  _Ong  阅读(2224)  评论(1编辑  收藏  举报