Tag Archives: Oracle

Pro*C 环境配置(RedHat +Oracle 10g)


Redhat+Oracle 10g环境搭建完毕后,终端中输入命令 proc
如果有如下错误提示:

[oracle@oracleserver ~]$ proc
proc: error while loading shared libraries: libclntsh.so.10.1: cannot open shared object file: No such file or directory

可以直接在用户配置文件 .bash_profile 中添加:

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

输入以下命令生效:

source .bash_profile

———————————————————-
编译.pc程序文件时,如果提示这样的错误:

Pro*C/C++: Release 10.2.0.1.0 - Production on Tue May 21 15:50:48 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

System default option values taken from: /home/oracle/OraHome1/oracle10g/precomp/admin/pcscfg.cfg

Error at line 34, column 11 in file /usr/include/stdio.h
# include 
..........1
PCC-S-02015, unable to open include file
Error at line 31, column 10 in file /usr/include/bits/types.h
#include 
.........1
PCC-S-02015, unable to open include file
Error at line 14, column 10 in file /usr/include/_G_config.h
#include 
.........1
PCC-S-02015, unable to open include file
Error at line 48, column 10 in file /usr/include/wchar.h
#include 
.........1
PCC-S-02015, unable to open include file
Error at line 48, column 10 in file /usr/include/wchar.h
#include 
.........1
PCC-S-02015, unable to open include file
Error at line 31, column 10 in file /usr/include/gconv.h
#include 
.........1
PCC-S-02015, unable to open include file
Syntax error at line 72, column 26, file /usr/include/gconv.h:
Error at line 72, column 26 in file /usr/include/gconv.h
                            unsigned char **, size_t *, int, int);
.........................1
PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following
:

   ... auto, char, const, double, enum, float, int, long,
   ulong_varchar, OCIBFileLocator OCIBlobLocator,
   OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
   OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
   short, signed, sql_context, sql_cursor, static, struct,
   union, unsigned, utext, uvarchar, varchar, void, volatile,
   a typedef name, exec oracle, exec oracle begin, exec,
   exec sql, exec sql begin, exec sql type, exec sql var,
The symbol "enum," was substituted for "size_t" to continue.

Syntax error at line 88, column 7, file /usr/include/gconv.h:
Error at line 88, column 7 in file /usr/include/gconv.h
                                  size_t *);
......1
PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following
:

   ... auto, char, const, double, enum, float, int, long,
   ulong_varchar, OCIBFileLocator OCIBlobLocator,
   OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
   OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
   short, signed, sql_context, sql_cursor, static, struct,
   union, unsigned, utext, uvarchar, varchar, void, volatile,
   a typedef name, exec oracle, exec oracle begin, exec,
   exec sql, exec sql begin, exec sql type, exec sql var,
The symbol "enum," was substituted for "size_t" to continue.

Syntax error at line 97, column 6, file /usr/include/gconv.h:
Error at line 97, column 6 in file /usr/include/gconv.h
                                        size_t *);
.....1
PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following
:

   ... auto, char, const, double, enum, float, int, long,
   ulong_varchar, OCIBFileLocator OCIBlobLocator,
   OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
   OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
   short, signed, sql_context, sql_cursor, static, struct,
   union, unsigned, utext, uvarchar, varchar, void, volatile,
   a typedef name, exec oracle, exec oracle begin, exec,
   exec sql, exec sql begin, exec sql type, exec sql var,
The symbol "enum," was substituted for "size_t" to continue.

Syntax error at line 106, column 3, file /usr/include/gconv.h:
Error at line 106, column 3 in file /usr/include/gconv.h
  __gconv_trans_fct __trans_fct;
..1
PCC-S-02201, Encountered the symbol "__gconv_trans_fct" when expecting one of th
e following:

   char, const, double, enum, float, int, long, ulong_varchar,
   OCIBFileLocator OCIBlobLocator, OCIClobLocator, OCIDateTime,
   OCIExtProcContext, OCIInterval, OCIRowid, OCIDate, OCINumber,
   OCIRaw, OCIString, short, signed, sql_context, sql_cursor,
   struct, union, unsigned, utext, uvarchar, varchar, void,
   volatile, a typedef name,

Error at line 53, column 11 in file /usr/include/libio.h
# include 
..........1
PCC-S-02015, unable to open include file
Error at line 33, column 10 in file /usr/include/string.h
#include 
.........1
PCC-S-02015, unable to open include file
Syntax error at line 0, column 0, file Desktop/test.pc:
Error at line 0, column 0 in file Desktop/test.pc
PCC-S-02201, Encountered the symbol "" when expecting one of the following:

   ; : an identifier, end-exec, random_terminal

Error at line 0, column 0 in file Desktop/test.pc
PCC-F-02102, Fatal error while doing C preprocessing

说明在 pcscfg.cfg 中系统头文件的位置不正确,需要重新设置:
查看pcscfg.cfg文件:

$[oracle@oracleserver ~]$ cat /home/oracle/OraHome1/oracle10g/precomp/admin/pcscfg.cfg
sys_include=(/ade/aime_rdbms_9819/oracle/precomp/public,/usr/include,/usr/lib/gcc-lib/i486-suse-linux/2.95.3/include,/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include,/usr/lib/gcc-lib/i386-redhat-linux7/2.96/include)
ltype=short

查找头文件 stddef.h 位置:

[root@oracleserver ~]# find / -name "stddef.h" -print
/usr/include/xulrunner-sdk-1.9/system_wrappers/stddef.h
/usr/include/linux/stddef.h
/usr/lib/bcc/include/stddef.h
/usr/lib/gcc/i386-redhat-linux/3.4.6/include/stddef.h
/usr/lib/gcc/i386-redhat-linux/4.1.1/include/stddef.h
/usr/lib/syslinux/com32/include/bitsize/stddef.h
/usr/lib/syslinux/com32/include/stddef.h
/usr/src/kernels/2.6.18-194.el5-i686/include/linux/stddef.h

比较发现,pcscfg.cfg中的/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include/usr/lib/gcc-lib/i386-redhat-linux7/2.96/include路径均无效,与实际系统中的路径不符,修改为/usr/lib/gcc/i386-redhat-linux/4.1.1/include/usr/lib/gcc/i386-redhat-linux/3.4.6/include 即可:

$ cat /home/oracle/OraHome1/oracle10g/precomp/admin/pcscfg.cfg
sys_include=(/ade/aime_rdbms_9819/oracle/precomp/public,/usr/include,/usr/lib/gcc-lib/i486-suse-linux/2.95.3/include,/usr/lib/gcc/i386-redhat-linux/4.1.1/include,/usr/lib/gcc/i386-redhat-linux/3.4.6/include)
ltype=short

写个简单的程序测试下:

$ proc test.pc
Pro*C/C++: Release 10.2.0.1.0 - Production on Tue May 21 16:07:16 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

System default option values taken from: /home/oracle/OraHome1/oracle10g/precomp/admin/pcscfg.cfg

转载请注明:Open Source Planet » Pro*C 环境配置(RedHat +Oracle 10g)