How to compile Oracle Call Interface (OCI) program?

Links: http://www.dbatools.net/experience/compile-oci-program.html

    On Linux/Unix we can use gcc to compile OCI source code. Use the following command to compile the text unload utility as 64 bit binary.

gcc -m64 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/rdbms/demo -L${ORACLE_HOME}/lib -lclntsh -o ociuldr.bin ociuldr.c

    I usually compile it as 32 bit executable file by the following command.

gcc -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/rdbms/demo -L${ORACLE_HOME}/lib32 -lclntsh -o ociuldr.bin ociuldr.c

    On IBM AIX, you need to use the following command to compile ociuldr to support 64 bit IO feature.

gcc -D_LARGE_FILES -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/rdbms/demo -L${ORACLE_HOME}/lib32 -lclntsh -o ociuldr.bin ociuldr.c

    On windows, I will use Microsoft Visual C++ as compiler. Run the following command to compile it.

set ORACLE_HOME=c:\oracle\product\10.2.0
set INCLUDE=%LIB%;%ORACLE_HOME%\oci\include
set LIB=%INCLUDE%;%ORACLE_HOME%\oci\lib\msvc
cl /ML /Feociuldr.exe ociuldr.c oci.lib

    For the Pro*C compilation, you just need to change the include file path and library path.

Comments (9)

On AIX, we need to add the following macro to support 64 bit IO function.

gcc -D_LARGE_FILES ......

Can i compile it with HP-UX 11.11,11.23 cc command?

/oracle>cc -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/rdbms/demo -L${ORACLE_HOME}/lib -o ociuldr.bin ociuldr.c
(Bundled) cc: "/oracle/product/10.2/rdbms/public/oratypes.h", line 30: warning 5: "signed" will become a keyword.
(Bundled) cc: "/oracle/product/10.2/rdbms/public/oratypes.h", line 30: error 1000: Unexpected symbol: "char".
(Bundled) cc: "/oracle/product/10.2/rdbms/public/oratypes.h", line 60: error 1000: Unexpected symbol: "b1".

I haven't tested the compilation on HPUX, you can install gcc on it.

hpux 11.11
complied use gcc 4.2.3 with 2nd command success
but it's slow
./ociuldr.bin test/test query="select * from j601" file='j601.csv' head=Yes

0 rows exported at 2009-05-23 16:25:19

500000 rows exported at 2009-05-23 16:26:24

only 500000 rows per second

it's fast
compare to exp direct=y/n


1791529857 j601.csv 11m 1s
2367672320 j601.dmp 4m 14s y
2377957376 j601.dmp 11m 14s n

I got the same result as you in other performance test.

faster than hrb_qiuyb 's ociuldr_v2.1

real 15m12.85s
user 14m28.19s
sys 0m25.60s

This is an awesome post, I will definitely be sure to add you to my list :)

Post a comment

Remember Me?

« Previous | Main | Next »

Powered by
Movable Type 5.01