我想使用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。
您是否嘗試過改變庫包括訂單在鏈接步驟?這可能很重要。 – mathematician1975
是的,我試過了,結果是一樣的。 – fdaines