2012-06-12 26 views
0

我想使用OCCI庫編譯一個基本程序。在Linux中使用g ++進行OCCI編譯

編譯任務是確定的。

g++ -I. -g -I/opt/oracle/product/10.2.0/db_1/precomp/public -I/opt/oracle/product/10.2.0/db_1/rdbms/public -I/opt/oracle/product/10.2.0/db_1/rdbms/demo -I/opt/oracle/product/10.2.0/db_1/plsql/public -I/opt/oracle/product/10.2.0/db_1/network/public -DMAX_SEND_SIZE=2000 -c -o test.o test.cpp 

輸出正常,生成test.o。但是,當我想要連接的目標文件,用下面的命令,

g++ -L/opt/oracle/product/10.2.0/db_1/lib/ -lclntsh -locci -o test test.o 

的連接任務失敗,輸出爲:

test.o: In function `main': 
/home/xxx/occi/test.cpp:128: undefined reference to `oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*, void*, unsigned int), void (*)(void*, void*))' 
/home/xxx/occi/test.cpp:170: undefined reference to `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)' 
/home/xxx/occi/test.cpp:158: undefined reference to `oracle::occi::SQLException::~SQLException()' 
/home/xxx/occi/test.cpp:158: undefined reference to `oracle::occi::SQLException::SQLException(oracle::occi::SQLException const&)' 
/home/xxx/occi/test.cpp:163: undefined reference to `oracle::occi::SQLException::what() const' 
/home/xxx/occi/test.cpp:158: undefined reference to `oracle::occi::SQLException::~SQLException()' 
test.o:(.gcc_except_table+0xe0): undefined reference to `typeinfo for oracle::occi::SQLException' 
collect2: ld returned 1 exit status 

我的環境簡歷:

  • 的Ubuntu Linux 11.04
  • gcc版本4.6.1(Ubuntu/Linaro 4.6.1-9ubuntu3)
  • ORACLE_HOME = /opt/oracle/product/10.2.0/db_1
  • LD_LIBRARY_PATH = /opt/oracle/product/10.2.0/db_1/lib
  • Oracle版本:10.2.0

你能幫助我請問,我真的需要在Linux中使用OCCI創建與Oracle的連接,我不想使用Pro * C。

+0

您是否嘗試過改變庫包括訂單在鏈接步驟?這可能很重要。 – mathematician1975

+0

是的,我試過了,結果是一樣的。 – fdaines

回答

0

要使用OCCI,您需要安裝Oracle提供的Instant Client(您是否安裝了?)。我使用的是Oracle 11.2,所以我的include目錄路徑是/usr/include/oracle/11.2/client64,我的共享庫是/usr/lib/oracle/11.2/client64/lib。

我在這裏看到

http://173.255.217.246:8000/mapnik_trac/wiki/OCCI 

即10.2路徑/usr/lib/oracle/10.2.0.4/client/include和/usr/lib/oracle/10.2.0.4/client/lib

在11.2,我還需要與nnz11 lib中爲http://xme.im/connect-oracle-database-eclipse-linux-using-occi

鏈接這是一個有用的博客描述關於即時客戶端http://oradim.blogspot.com/2009/08/getting-started-with-occi-linux-version.html

相關問題