Saturday, 25 January 2014

Basics of PRO C/C++ and Compilation Procedure of PRO C/C++


Pro c is the embedded SQL programming language. It is used in the oracle databases for manipulating the databases. It is based on the ANSI C compliance and also supports the multithread Programming. The extension of Proc  file is .pc
First precompile the proc file to produce a respective c/c++ file.
To precompile the pro *C/C++ file you need just type the following command.

proc filename.pc

While precompiling the proc file the oracle gives some options in form of name value pairs. This options were used to configure according to our needs.

There are several parameters to be configured before you precompile the proc file.

1. Make sure that $ORACLE_HOME environmental variable is set Correctly.
If not path is correctly set, Set using the following command in your terminal.
To verify the path set use the following command

2. Export the $ORACLE_HOME to your currently working shell.
Eg export $ORACLE_PATH

3. LD_LIBRARY_PATH. This is the environmental variable in linux that contains the list of dynamic linking files. Make sure that LD_LIBRARY_PATH is set correctly.

4.  In case the ELF(Executable and linking format) error occurs then you are making some mistakes with the portability (32 to 64 bit portability ,64 bit 32 bit portability)

when that error occurs i.e., while compiling the precompiled code,  use m-64 or m-32 option in gcc. It is used for compiling the code as 32 or 64 bit.

After Precompilation:

After Precompiling the proc file,  then corresponding cpp file will be generated. Then that cpp file need to be compiled like this

g++ connect.cpp  -L/path/to/oracle/10.2.0/db_1/lib -lclntsh -m64