項目要用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參數。, 謝謝!