【问题标题】:OCCI compilation with g++ in Linux在 Linux 中使用 g++ 进行 OCCI 编译
【发布时间】:2012-06-12 15:46:50
【问题描述】:

我正在尝试使用 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
  • Oracle 版本:10.2.0

你能帮帮我吗?我真的需要在 Linux 中使用 OCCI 创建到 Oracle 的连接,我不想使用 Pro*C。

【问题讨论】:

  • 您是否尝试在链接步骤中更改库包含顺序?这可能很重要。
  • 是的,我试过了,结果是一样的。

标签: c++ oracle g++ occi


【解决方案1】:

要使用 OCCI,您需要安装 Oracle 提供的 Instant Client(您安装了吗?)。我使用的是 Oracle 11.2,所以我的包含目录路径是 /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 库

这是一篇关于 Instant Client http://oradim.blogspot.com/2009/08/getting-started-with-occi-linux-version.html 的有用博客

【讨论】:

    猜你喜欢
    • 2013-07-21
    • 2018-07-09
    • 1970-01-01
    • 2012-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-14
    • 1970-01-01
    相关资源
    最近更新 更多