我正在尝试使用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
我的环境恢复:
你能帮帮我吗?我真的需要在Linux中使用OCCI建立与Oracle的连接,我不想使用Pro * C.
答案 0 :(得分: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中,我还需要首先以http://xme.im/connect-oracle-database-eclipse-linux-using-occi
与nnz11 lib链接这是关于Instant Client http://oradim.blogspot.com/2009/08/getting-started-with-occi-linux-version.html
的有用博客描述