最近我把我的gcc从4.1.2升级到5.2.0。
这导致OCCI库的链接错误:
我试图运行的源代码:
#include <iostream>
#include <occi.h>
using namespace oracle::occi;
using namespace std;
int main (int argc, char *argv[])
{
Environment *env;
Connection *conn;
oracle::occi::MetaData metaData = conn->getMetaData ((char *)"PERSON_OBJ");
metaData.getString(MetaData::ATTR_NAME);
return(0);
}链接错误:
gmake -f /home/davidd/temp.mak CFG=Debug
g++ -g "-Wl,-rpath,/omniqdir/arch/x86_64/release/lib:/omniqdir/instantclient_12_1:/usr/lib,-rpath-link,/omniqdir/arch/x86_64/release/lib:/omniqdir/instantclient_12_1:/usr/lib,-ldl,-lpthread" /omniqdir/arch/x86_64/release/lib/libjemalloc.so -o "Debug/temp" Debug/temp.o /omniqdir/instantclient_12_1/libocci.so /omniqdir/instantclient_12_1/libclntsh.so
Debug/temp.o: In function `main':
temp.cpp:(.text+0xac): undefined reference to `_ZNK6oracle4occi8MetaData9getStringB5**cxx11**ENS1_6AttrIdE'
collect2: error: ld returned 1 exit status
gmake: *** [Debug/temp] Error 1我注意到,未定义的引用包含与c++11相关的符号,我猜这与我正在使用的新gcc编译器有关。
函数声明来自occiControl.h
OCCI_STD_NAMESPACE::string getString(元数据::attrid attrid)
我正在使用CentOS6.6和最新的OCCI版本,即实例化客户机-Basiclit-linux.x64-12.1.0.2.0。
有什么想法吗?
谢谢你,大卫
发布于 2015-11-22 16:16:31
这几乎可以肯定是因为gcc 5中的新ABI和OCCI库所期望的ABI之间不兼容。
在构建代码之前,您可以尝试将_GLIBCXX_USE_CXX11_ABI定义为0,这将导致gcc 5使用旧的ABI。
另外,请注意,在尝试使用带有clang的OCCI进行构建及其libc++ (http://libcxx.llvm.org/)的实现时,也存在类似的问题。(这是咬我的那个)。
您可以在以下网站了解更多信息:https://gcc.gnu.org/gcc-5/changes.html#libstdcxx和abi.html
发布于 2018-04-06 14:02:06
我在Solaris 11中也遇到了类似的问题。通过Linker选项解决了这个问题:
-m64 -lCstd
希望能帮上忙。
https://stackoverflow.com/questions/32309029
复制相似问题