无法使用 OTLv4 库编译 C++ 代码

Posted

技术标签:

【中文标题】无法使用 OTLv4 库编译 C++ 代码【英文标题】:Unable to compile C++ code using OTLv4 library 【发布时间】:2011-12-29 07:35:01 【问题描述】:

您能帮我弄清楚这里缺少什么吗? 我正在尝试使用 OTL 4 库编译 c++ 程序,但出现错误。

环境详情:

我在 Ubuntu 11.04 VM 上安装了 Oracle DB XE 10G。 SQL*Plus 和服务器本身正在正常运行。

编译代码为:

g++ -o <output>.exe <source>.cpp -I$ORACLE_HOME/rdbms/public -I$ORACLE_HOME/rdbms/demo -L$ORACLE_HOME/lib -lclntsh

错误是:

/usr/bin/ld: warning: libnnz10.so, needed by /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so, not found (try using -rpath or -rpath-link)  
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so: undefined reference to `nztSetAppDefaultLocation'  
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so: undefined reference to `nzos_DisableClientAuthentication'  
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so: undefined reference to `nzos_Create_Ctx'  
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so: undefined reference to `_intel_fast_memcpy'  
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so: undefined reference to `nzgbllsm_location_shared_memory'  
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so: undefined reference to `__intel_cpu_indicator'  
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so: undefined reference to `nzosSCCS_SetCRLCacheSize'  
...a whole lot more undefined references...   
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so: undefined reference to `nzssGSL_GetSecretLength'  
collect2: ld returned 1 exit status  

错误说明: 当我检查时,当我查看我的 $ORACLE_HOME/lib 目录时,libnnz10.so 存在。

【问题讨论】:

【参考方案1】:

今天下午我搞定了,现在可以编译了。 因此,如果有人遇到与我相同的问题,这里的解决方案是:

$ORACLE_HOME/lib 路径添加到您的$LD_LIBRARY_PATH

为方便起见,您也可以将其添加到您的.bashrc 个人资料中,如下所示:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH  

就是这样!

PS:我想早点发这个,但似乎我仍然缺乏代表点为了回答我的问题自己的问题早于 8 小时。

【讨论】:

【参考方案2】:

不确定为什么有必要,但您可以尝试将-lnnz10 添加到您的命令中。

(Google 显示人们使用了这个额外的参数,但无法很快看到有人解释原因;其他选项似乎是设置 LD_LIBRARY 路径或将 $ORACLE_HOME/lib 添加到 /etc/ld.so.conf...)

【讨论】:

以上是关于无法使用 OTLv4 库编译 C++ 代码的主要内容,如果未能解决你的问题,请参考以下文章

为啥我无法在 win64 上使用 boost 1.54 编译 VS2012 C++ 代码?

无法编译 protoc 生成的 (C++) 类

无法使用 libpqxx 和 xcode4 (c++) 进行编译

无法将 c++ 项目完全编译和链接为静态库

无法在 Windows 代码块上使用 gcc 编译器编译 c++“hello world”

Allegro 库安装