[C++]linux下使用occi连接oracle遇到的两个错误

-----------------------------Cryking原创------------------------------
-----------------------转载请注明出处,谢谢!------------------------ 

 

我的makefile如下:

includepath=${ORACLE_HOME}/precomp/public
occpath=${ORACLE_HOME}/oci/include
libpath=${ORACLE_HOME}/lib
libfile=-L${libpath} #/usr/lib/libstdc++.so.5
incfile=-I${includepath}
occifile=-I${occpath}

cppOra:cppOra.cc
        g++ -o cppOra cppOra.cc  ${occifile} ${incfile} ${libfile} -lclntsh -locci -Wall -O -g
clean:
        rm cppOra

PS:-I是指定include路径,-L是指定lib路径

下载的occi压缩包为instantclient-basic-linux32-11.2.0.1.zip    URL是http://www.oracle.com/technetwork/topics/linuxsoft-082809.html

linux下我unzip后的路径为: /home/oracle/cry/instantclient_11_2

 

1.编译错误:
/usr/bin/ld: warning: libnnz11.so, needed by /usr/lib/oracle/11.1/client/lib/libclntsh.so, not found (try using -rpath or -rpath-link)
/usr/lib/oracle/11.1/client/lib/libclntsh.so: undefined reference to `nztSetSqlnetFunc'
/usr/lib/oracle/11.1/client/lib/libclntsh.so: undefined reference to `nztSetAppDefaultLocation'
/usr/lib/oracle/11.1/client/lib/libclntsh.so: undefined reference to `nzos_DisableClientAuthentication'

..

解决方法:

还是库连接的问题,在/etc/ld.so.conf中添加 /home/oracle/cry/instantclient_11_2  后正常.

 

2.执行错误:

./cppOra: error while loading shared libraries: libnnz11.so: cannot open shared object file: No such file or directory

解决:

export  LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib

 

其实质还是lib库文件链接的问题.

最后执行正常如下:

[oracle@oracleserver cry]$ ./cppOra
debug1
7369  AND  SMITH
2013-07-14 02:00:29
7499  AND  ALLEN
2013-07-14 02:00:29
7521  AND  WARD
2013-07-14 02:00:29
7566  AND  JONES
2013-07-14 02:00:29
7654  AND  MARTIN
2013-07-14 02:00:29
7698  AND  BLAKE
2013-07-14 02:00:29
7782  AND  CLARK
2013-07-14 02:00:29
7788  AND  SCOTT
2013-07-14 02:00:29
7839  AND  KING
2013-07-14 02:00:29
7844  AND  TURNER
2013-07-14 02:00:29
7876  AND  ADAMS
2013-07-14 02:00:29
7900  AND  JAMES
2013-07-14 02:00:29
7902  AND  FORD
2013-07-14 02:00:29
7934  AND  MILLER
2013-07-14 02:00:29
SELECT  SUCCESS

 

你可能感兴趣的:([C++]linux下使用occi连接oracle遇到的两个错误)