Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am trying to connect oracle database with simple c++ code with eclipse on redhat.
The code is...
C#
#include <iostream>
#include <occi.h>

using namespace std;
using namespace oracle::occi;
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("gldbuser", "gldbuser", "MYDATABSE");

        stmt = con->createStatement("select * from example");
        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;
}

nment->terminateConnection(con);

}catch(oracle::occi::SQLException &e){
std::cout<<e.what();
}

return 0;
}
nment->terminateConnection(con);

}catch(oracle::occi::SQLException &e){
std::cout<<e.what();
}

return 0;
}




Now the problem is..
**** Build of configuration Debug for project OCCIExample ****

make all
Building target: OCCIExample
Invoking: GCC C++ Linker
g++ -L"/root/awa_c++/OCCIExample" -o"OCCIExample" ./main.o -locci
/usr/bin/ld: cannot find -locci
collect2: ld returned 1 exit status
make: *** [OCCIExample] Error 1tus

what is the solution?
thanks & regards
AK
Posted
Comments
Richard MacCutchan 19-Oct-11 9:09am    
Where is your libocci.a file stored?
Awa_tcp 20-Oct-11 6:39am    
sir,
The path of libocci.so is /usr/lib/oracle/10.2.0.4/client/lib

thanks for rply.
AK
Richard MacCutchan 20-Oct-11 8:23am    
Then you need to add it to the linker options with a -L directive.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900