Problem in oracle database connection with c++ through OCCI. [message #1695748] |
Mon, 18 May 2015 22:35 |
Rahul Vishawakarma Messages: 1 Registered: May 2015 |
Junior Member |
|
|
Hi to all,
I have eclipse centos (on VMware machine 1) and oracle 11gr2 (on VMware machine 2). Both have good interconncetivity(sqlplus working from client to server). I want to access oracle database from c++ through OCCI. but hangup with this error :-
1. undefined reference to `oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*, void*, unsigned int), void (*)(void*, void*))'
2. undefined reference to `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)'
CODE is :-
#include <occi.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace oracle::occi;
using namespace std;
class Employees {
public:
Employees();
virtual ~Employees();
void List();
private:
Environment *env;
Connection *con;
string user;
string passwd;
string db;
};
int main (void)
{
Employees *pEmployees = new Employees();
pEmployees->List();
delete pEmployees;
cout << "ENTER to continue...";
cin.get();
return 0;
}
Employees::Employees()
{
user = "scott";
passwd = "tiger";
db = "oel11gr2:1521/ora11gr2";
env = Environment::createEnvironment(Environment::DEFAULT);
try
{
con = env->createConnection(user, passwd, db);
}
catch (SQLException& ex)
{
cout << ex.getMessage();
exit(EXIT_FAILURE);
}
}
Employees::~Employees()
{
env->terminateConnection (con);
Environment::terminateEnvironment (env);
}
void Employees::List()
{
Statement *stmt = NULL;
ResultSet *rs = NULL;
string sql = "select ename from emp";
try
{
stmt = con->createStatement(sql);
}
catch (SQLException& ex)
{
cout << ex.getMessage();
}
if (stmt)
{
try
{
stmt->setPrefetchRowCount(32);
rs = stmt->executeQuery();
}
catch (SQLException& ex)
{
cout << ex.getMessage();
}
if (rs)
{
cout << endl << setw(8) << left << "ENAME" << endl;
while (rs->next()) {
cout << setw(8) << left << rs->getString(1)
<< endl;
}
cout << endl;
stmt->closeResultSet(rs);
}
con->terminateStatement(stmt);
}
}
I installed linux instant client basic, sqlplus and sdk.
even I added library in eclipse as :
------------------------------------
/usr/lib/oracle/11.2/client/lib
/opt/oracle/app/oracle/product/11.2.0/dbhome_1/instantclient
/opt/oracle/app/oracle/product/11.2.0/dbhome_1/lib
/usr/lib
/lib
and included header files as :
------------------------------
/usr/include/oracle/11.2/client
/opt/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/public
/usr/local/include/c++/4.8.3
/usr/include
But problem is same : "undefined reference to ......"
By searching in web i found this is linker problem. But how to fix it ......
|
|
|
Powered by
FUDForum. Page generated in 0.02580 seconds