我尝试用一个小型的C++程序使用Python cType来测试,它使用Oracle OCI来查看是否可以使用这样的组合。它可以编译为.so库文件,但是当我试图从Python中使用它时,我会遇到一个很好的链接器错误,我想:
#include <string>
#include <iostream>
#include "occi.h"
using namespace std;
using namespace oracle::occi;
static string userName = "****";
static string passWord = "****";
static string connectString = "****";
class Account{
public:
bool updateAccount(){
bool updated = false;
try{
Environment *env = Environment::createEnvironment(Environment::DEFAULT);
Connection *conn = env->createConnection(userName,passWord,connectString);
Statement *stmt = conn->createStatement("select * from test");
ResultSet *rs = stmt->executeQuery();
while(rs->next()){
cout<<rs->getString(1)<<endl;
cout<<rs->getString(2)<<endl;
cout<<rs->getString(3)<<endl;
}
conn->terminateStatement(stmt);
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
}catch(...){
}
return updated;
}
};
extern "C" {
Account* Account_new(){ return new Account(); }
bool Account_updateAccount(Account* account){ account->updateAccount(); }
}
在
^{pr2}$运行时出错测试副本公司名称:
Traceback (most recent call last):
File "./ctest.py", line 7, in <module>
lib = ctypes.cdll.LoadLibrary('/oracle/ctypes/occi.so')
File "/usr/local/lib/python2.6/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/usr/local/lib/python2.6/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: ld.so.1: python2.6: fatal: relocation error: file /oracle/ctypes/occi.so: symbol _ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_jEPFS3_S3_S3_jEPFvS3_S3_E: referenced symbol not found
有什么想法,可能是使用Oracle即时客户端libs的问题吗。在过去,当我试图编译其他第三方库时,我见过这些奇怪的问题?在
谢谢
目前没有回答
相关问题 更多 >
编程相关推荐