我正在尝试使用 OCCI 库编译一个基本程序。
编译任务OK。
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
输出OK,生成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
- 甲骨文版本:10.2.0
你能帮我吗?,我真的需要在 Linux 中使用 OCCI 创建到 Oracle 的连接,我不想使用 Pro*C。