step one:将.pc文件预编译为.c
[ecif@localhost zyctest]$ proc sample1.pc
显示信息:
Pro*C/C++: Release 10.2.0.1.0 - Production on Tue Apr 13 14:07:05 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
System default option values taken from: /home/oracle/oracle/product/10.2.0/db_1/precomp/admin /pcscfg.cfg
step two:编译.c文件,生成目标文件
gcc -L$ORACLE_HOME/precomp/public -I/home/oracle/oracle/product/10.2.0/db_1/precomp/public/ -c sample1.c
提示警告:
sample1.c: In function `main':
sample1.c:236: warning: return type of 'main' is not `int'
step three:链接目标文件,生成可执行程序
gcc -L$ORACLE_HOME/lib -lclntsh -o sample1 sample1.o
警告:
sample1.o(.text+0x381): In function `main':
: warning: the `gets' function is dangerous and should not be used.
step four:执行文件
./sample1
在执行./samle1出现:
error while loading shared libraries: /oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1: cannot restore segment prot after reloc: Permission denied
解决的办法是:
chcon -t texrel_shlib_t /oracle/product/10.2.0/db_1/lib/*.so