1、proc编译器配置问题
在使用proc将.pc文件编译成.c文件时出现一堆的错误,网上的答案七杂八杂的,都没有解决我的问题。
如下是我在使用过程中的一些错误:
由于我可能比较笨,实在是受不了网上那些奇奇怪怪的答案,所以只能乖乖的自己去琢磨,根据错误来看,应该是跟头文件有关
所以我查询了下proc编译器的配置文件,如下
PS:这个是我后面改回来的,反正差不多就是这样。。。。
然后我一开始想是不是这里面涉及到的gcc版本跟我的系统上的不一样,然后就直接去一个一个进去看,例如cd /usr/lib/gcc-lib/x86_64-redhat-linux/3.4.3/include
得出的结果是未找到这个文件,因为我的CentOS的gcc有两个版本(不是特别懂)就是有一个4.8.2和4.8.5的文件夹,其中刚好有Include文件夹,点开有一堆gcc头文件
所以我就将原本的配置文件的版本参数改成这两个版本参数。
然后,重新编译,成功!如下:
另:这是配置文件的路径:$ORACLE_HOME/precomp/admin/pcscfg.cfg
2、我们成功使用proc xxxx.pc编译成.c文件了,但是却不能编译由C++所写的文件,否则出现以下错误:
[oracle@localhost mytest]$ proc testHello1.pc
Pro*C/C++: Release 11.2.0.1.0 - Production on Sun Apr 1 14:58:27 2018
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
System default option values taken from: /data/oraacle/product/11.2.0/db_1/precomp/admin/pcscfg.cfg
Error at line 6, column 9 in file testHello1.pc
#include<iostream>
........1
PCC-S-02015, unable to open include file
Syntax error at line 9, column 7, file testHello1.pc:
Error at line 9, column 7 in file testHello1.pc
using namespace std;
......1
PCC-S-02201, Encountered the symbol "namespace" when expecting one of the follow
ing:
; , = ( [
Syntax error at line 16, column 1, file testHello1.pc:
Error at line 16, column 1 in file testHello1.pc
{
1
PCC-S-02201, Encountered the symbol "{" when expecting one of the following:
; , = ( [
The symbol ";" was substituted for "{" to continue.
Syntax error at line 0, column 0, file testHello1.pc:
Error at line 0, column 0 in file testHello1.pc
PCC-S-02201, Encountered the symbol "<eof>" when expecting one of the following:
; { } ( * & + - ~ ! ^ ++ -- ... auto, break, case, char,
const, continue, default, do, double, enum, extern, float,
for, goto, if, int, long, ulong_varchar, OCIBFileLocator
OCIBlobLocator, OCIClobLocator, OCIDateTime,
OCIExtProcContext, OCIInterval, OCIRowid, OCIDate, OCINumber,
OCIRaw, OCIString, register, return, short, signed, sizeof,
sql_context, sql_cursor, static, struct, switch, typedef,
union, unsigned, utext, uvarchar, varchar, void, volatile,
while, an identifier, a typedef name, a precompiled header,
a quoted string, a numeric constant, exec oracle,
exec oracle begin, exec, exec sql, exec sql begin,
exec sql type, exec sql var, exec sql include,
Error at line 0, column 0 in file testHello1.pc
PCC-F-02102, Fatal error while doing C preprocessing
这是因为预编译工具proc,它是完成Pro*C源程序到纯C程序的转换
proc iname=filename [OptionName1=value1]…[OptionNameN=valueN]
常用编译选项
INAME=path and filename (name of the input file)
ONAME=path and filename (name of the output file)
INCLUDE=path (头文件所在路径)
--INCLUDE =路径名 或 INCLUDE =(路径名1,路径名2)
PARSE=FULL | PARTIA | NONE (default FULL for C, Others for C++)
CODE=ANSI_C | CPP (default ansi_c)
USERID=username/password
以上是它的常用编译选项,如果要想将.pc转换成.cc的c++源程序要这样:proc iname=test.pc parse=none code=cpp oname=test.cc
然后编译c++源程序时,要使用g++,这应该都知道的,哈哈哈~
PS:我觉得proc的编译挺麻烦的,要编译两次,后面自己写了个脚本方便多了,然后才发现有个makefile这个东西。。。。。。。。。