Home » Developer & Programmer » Precompilers, OCI & OCCI » Problem, how to connect c++ and Oracle (Linux, Oracle 10g)
Problem, how to connect c++ and Oracle [message #348675] Wed, 17 September 2008 09:50 Go to next message
yongluouk
Messages: 9
Registered: September 2008
Junior Member
My OS is Linux and I installed Oracle 10.2. Everything is fine.
I can use sqlplus, exp, imp etc with no problem.

Now I have created another linux user test in /home/test.
I unzipped basic-10.2xxxxxx.zip (/home/test/instantclient_10_2) and exported LD_LIBRARY_PATH.
I guess I have installed instant client in this way.

My testOra.cpp:

#include <occi.h>

int main()
{
return 0;
}

This test.cpp would not compile. It cannot find occi.h

Would you please tell me what to do?

Thank you in advance.



Re: Problem, how to connect c++ and Oracle [message #348682 is a reply to message #348675] Wed, 17 September 2008 10:30 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Include occi.h directory in your INCLUDE path.

Regards
Michel
Re: Problem, how to connect c++ and Oracle [message #348920 is a reply to message #348682] Thu, 18 September 2008 05:31 Go to previous messageGo to next message
yongluouk
Messages: 9
Registered: September 2008
Junior Member
Thank you very much, Michel.

The occi.h and other related header files are in
$ORACLE_HOME/rdbms/public/.
I changed the permission, but I still cannot use occi.h.
Then I copy all files to /home/test/public/, and it compiles.
But I am not sure whether this is a right way.

Yong
Re: Problem, how to connect c++ and Oracle [message #348941 is a reply to message #348920] Thu, 18 September 2008 06:02 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You should investigate why it can't access the first file.
Is $ORACLE_HOME set and exported?

Regards
Michel
Re: Problem, how to connect c++ and Oracle [message #348957 is a reply to message #348941] Thu, 18 September 2008 06:52 Go to previous messageGo to next message
yongluouk
Messages: 9
Registered: September 2008
Junior Member
Michel, thank you very much again.

I have a root user and have permission to change anything.

In my test user, /home/test, the .bashrc file looks like:

...
export LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/home/test/instantclient_10_2/
.....

There is not other exports for test user.

The user oracle, /home/oracle, in the .bash_profile file,

...
export ORACLE_HOME=...
export ORACLE_SID=...
.....

Would you please tell me what others I should export?
I am new for B shell script.

Yong
Re: Problem, how to connect c++ and Oracle [message #348960 is a reply to message #348957] Thu, 18 September 2008 07:00 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
All those you use in your compile shell script or makefile and are inherited.

Regards
Michel
Re: Problem, how to connect c++ and Oracle [message #348984 is a reply to message #348960] Thu, 18 September 2008 08:37 Go to previous messageGo to next message
yongluouk
Messages: 9
Registered: September 2008
Junior Member
Hi Michel,

I am not sure what you mean.

But I have got a new problem. My testOra.cpp is the following.

#include <occi.h>
using namespace oracle::occi;

int main()
{
Environment* env = Environment::createEnvironment();
...
return 0;
}

Compile command:
g++ -I /home/test/public/ testOra.cpp

Error: undefined reference Environment::createEnvironment....

Thank you,

Yong
Re: Problem, how to connect c++ and Oracle [message #348987 is a reply to message #348984] Thu, 18 September 2008 08:49 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Try adding -I $ORACLE_HOME/rdbms/public/

Sorry, can't help you on "Environment", I don't use OCCI but Pro*C, so don't know OCCI classes (is "Environment" a OCCI class?).

Regards
Michel
Re: Problem, how to connect c++ and Oracle [message #349029 is a reply to message #348987] Thu, 18 September 2008 10:56 Go to previous message
yongluouk
Messages: 9
Registered: September 2008
Junior Member
Hi Michel,

Thank you anyway!

Best regards,

Yong
Previous Topic: Problems running query in PRO*C that works in SQLPLUS
Next Topic: Problem with OCCI
Goto Forum:
  


Current Time: Thu Mar 28 15:38:00 CDT 2024