[英]error while using occi for writing a udf for oracle db
我正在嘗試使用標題occi.h編譯cpp代碼,我正在使用的代碼是`
#include <iostream>
#include <occi.h>
using namespace std;
int main(){
oracle::occi::Environment* environment;
oracle::occi::Connection *con;
oracle::occi::Statement* stmt;
oracle::occi::ResultSet* res;
try
{
environment = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
con = environment->createConnection("sys", "root","xe");
stmt = con->createStatement("select * from customers");
res = stmt->executeQuery();
while (res->next())
std::cout<<res->getInt(1)<<" "<<res->getString(2)<<std::endl;
stmt->closeResultSet(res);
con->terminateStatement(stmt);
environment->terminateConnection(con);
}catch(oracle::occi::SQLException &e){
std::cout<<e.what();
}
return 0;
}`
運行以下命令時出現以下錯誤:-g ++ -I / root / instantclient_11_2 / sdk / include -L $ ORACLE_HOME / lib:/ root / Shared / instantclient_11_2_lib / -L $ ORACLE_HOME / rdbms / lib cpp_db_conn.cpp
錯誤:-/tmp/ccjcKsxz.o:在函數main': udf.cpp:(.text+0x26): undefined reference to
oracle :: occi :: Environment :: createEnvironment(oracle :: occi :: Environment :: Mode的main': udf.cpp:(.text+0x26): undefined reference to
,void *,void *( )(void ,無符號長),void *( )(void ,void *,無符號長),void( )(void ,void *))'/tmp/ccjcKsxz.o:(.gcc_except_table + 0x80):對oracle :: occi :: SQLException的`typeinfo的未定義引用collect2:ld返回1退出狀態
oracle :: occi :: Connection |為什么在這里有空格???? **而不在這里?
我可以告訴你我的情況。 顯然,這是一個位不匹配的問題。
我的環境是默認設置為64位編譯器的“ Microsoft SDK v7.0”
不幸的是,我的oracle客戶端是32位的,版本是Instantclient-basic-nt-12.1.0.2.0。
我的錯誤也一樣。
因此,我將編譯器更改為32位。
setenv /x86
然后,所有問題都消失了。
祝你有美好的一天。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.