一、proc編譯器配置問題linux
在使用proc將.pc文件編譯成.c文件時出現一堆的錯誤,網上的答案七雜八雜的,都沒有解決個人問題。ios
以下是我在使用過程當中的一些錯誤:c++
因爲我可能比較笨,實在是受不了網上那些奇奇怪怪的答案,因此只能乖乖的本身去琢磨,根據錯誤來看,應該是跟頭文件有關sql
因此我查詢了下proc編譯器的配置文件,以下oracle
PS:這個是我後面改回來的,反正差很少就是這樣。。。。ide
而後我一開始想是否是這裏面涉及到的gcc版本跟個人系統上的不同,而後就直接去一個一個進去看,例如cd /usr/lib/gcc-lib/x86_64-redhat-linux/3.4.3/include工具
得出的結果是未找到這個文件,由於個人CentOS的gcc有兩個版本(不是特別懂)就是有一個4.8.2和4.8.5的文件夾,其中恰好有Include文件夾,點開有一堆gcc頭文件spa
因此我就將本來的配置文件的版本參數改爲這兩個版本參數。code
而後,從新編譯,成功!以下:blog
另:這是配置文件的路徑:$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這個東西。。。。。。。。。