卡在这里好几天了,谁能帮忙,不胜感激。主要问题是关于在 mac 上使用 oracle Precompiler。
我是这样一步一步尝试的: 1.作为Oracle官方文档,我下载了三个文件:
1.instantclient-basic-macos.x64-18.1.0.0.0.zip
2.instantclient-sdk-macos.x64-18.1.0.0.0-2.zip
3.instantclient-sqlplus-macos.x64-18.1.0.0.0.zip
2.然后按照这里提到的步骤https://github.com/InstantClientTap/homebrew-instantclient:
brew tap InstantClientTap/instantclient
brew install instantclient-basic
brew install instantclient-sdk
brew install instantclient-sqlplus
我使用 sqlplus 连接到在 docker 中成功运行的 Oracle 服务器。
3.BUT,由于此工具不提供安装预编译器。所以我下载
了 instantclient-precomp-macos.x64-12.2.0.1.0-2.zip 然后解压。
4.我有一个文件夹名称precomp,它有一个文件夹名称admin,在admin中我有两个文件pcbcfg.cfg和pcscfg.cfg,我将precomp文件夹放入/usr/local/lib/中,当我使用proc
command时提到在我的终端中是这样的:
System default option values taken from:/usr/local/lib/precomp/admin/pcscfg.cfg.
5.另外,我有一个文件夹名称sdk,因为我已经通过自制软件安装了sdk,所以我将sdk中的exec文件名proc和procob复制到/usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/lib/sdk/
6.然后我把所有的.h文件放在include文件夹/usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/lib/sdk/include
中以防万一,我也将它们复制到.h文件中usr/local/include
。
7.我改变了 pcscfg.cfg 中的行,如下所示:
sys_include=($ORACLE_HOME/sdk/include,/usr/include,/usr/local/include/,/usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/include,/usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/lib/sdk/include,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include)
这就是我所做的一切。
所以我只写了一个test.pc:
#include<arpa/inet.h>
#include<string.h>
#include<stdio.h>
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
varchar username[20],passwd[20],dbn[20];
EXEC SQL END DECLARE SECTION;
strcpy(username.arr, "c##yuyu");
username.len = strlen("c##yuyu");
strcpy(passwd.arr,"123456");
passwd.len = strlen("123456");
strcpy(dbn.arr, "ORCLCDB.localdomain");
dbn.len = strlen("ORCLCDB.localdomain");
EXEC SQL CONNECT: username IDENTIFIED BY :passwd USING :dbn;
if(sqlca.sqlcode !=0){
printf("login failed\n");
}
printf("login success\n");
然后 commond proc test.pc
,不幸的是出现了很多错误:
Pro*C/C++: Release 18.0.0.0.0 - Production on Mon Aug 12 17:58:05 2019
Version 18.1.0.0.0
Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.
System default option values taken from: /usr/local/lib/precomp/admin/pcscfg.cfg
Syntax error at line 95, column 1, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/_OSByteOrder.h:
Error at line 95, column 1 in file /Applications/Xcode.app/Contents/Developer/Pl
atforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/_OSByteOrd
er.h
uint16_t
1
PCC-S-02201, Encountered the symbol "uint16_t" when expecting one of the followi
ng:
; , = ( [
The symbol ";" was substituted for "uint16_t" to continue.
Syntax error at line 104, column 1, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/_OSByteOrder.h:
Error at line 104, column 1 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/_OSByteOr
der.h
uint32_t
1
PCC-S-02201, Encountered the symbol "uint32_t" when expecting one of the followi
ng:
; , = ( [
The symbol ";" was substituted for "uint32_t" to continue.
Syntax error at line 113, column 1, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/_OSByteOrder.h:
Error at line 113, column 1 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/_OSByteOr
der.h
uint64_t
1
PCC-S-02201, Encountered the symbol "uint64_t" when expecting one of the followi
ng:
; , = ( [
The symbol ";" was substituted for "uint64_t" to continue.
Syntax error at line 52030, column 62, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h:
Error at line 52030, column 62 in file /Applications/Xcode.app/Contents/Develope
r/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityIn
ternal.h
#define __API_AVAILABLE_GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
.............................................................1
PCC-S-02014, Encountered the symbol "..." when expecting one of the following:
an identifier, define, elif, else, endif, error, if, ifdef,
ifndef, include, include_next, line, pragma, undef, exec,
sql, begin, end, var, type, oracle,
an immediate preprocessor command, a C token, create,
function, package, procedure, trigger, or, replace,
Syntax error at line 97, column 9, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/types.h:
Error at line 97, column 9 in file /Applications/Xcode.app/Contents/Developer/Pl
atforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/types.h
typedef quad_t * qaddr_t;
........1
PCC-S-02201, Encountered the symbol "quad_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,
The symbol "enum," was substituted for "quad_t" to continue.
Syntax error at line 33, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_iovec_t.h:
Error at line 33, column 2 in file /Applications/Xcode.app/Contents/Developer/Pl
atforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_iovec_
t.h
size_t iov_len; /* [XSI] Size of region iov_base points to */
.1
PCC-S-02201, Encountered the symbol "size_t" when expecting one of the 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,
The symbol "enum," was substituted for "size_t" to continue.
Syntax error at line 303, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:
Error at line 303, column 2 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h
socklen_t sae_srcaddrlen; /* size of source address */
.1
PCC-S-02201, Encountered the symbol "socklen_t" when expecting one of the follow
ing:
} 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,
The symbol "enum," was substituted for "socklen_t" to continue.
Syntax error at line 305, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:
Error at line 305, column 2 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h
socklen_t sae_dstaddrlen; /* size of destination address *
/
.1
PCC-S-02201, Encountered the symbol "socklen_t" when expecting one of the follow
ing:
} 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,
The symbol "enum," was substituted for "socklen_t" to continue.
Syntax error at line 406, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:
Error at line 406, column 2 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h
sa_family_t sa_family; /* [XSI] address family */
.1
PCC-S-02201, Encountered the symbol "sa_family_t" when expecting one of the foll
owing:
} 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,
The symbol "enum," was substituted for "sa_family_t" to continue.
Syntax error at line 439, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:
Error at line 439, column 2 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h
sa_family_t ss_family; /* [XSI] address family */
.1
PCC-S-02201, Encountered the symbol "sa_family_t" when expecting one of the foll
owing:
} 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,
The symbol "enum," was substituted for "sa_family_t" to continue.
Syntax error at line 543, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:
Error at line 543, column 2 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h
socklen_t msg_namelen; /* [XSI] size of address */
.1
PCC-S-02201, Encountered the symbol "socklen_t" when expecting one of the follow
ing:
} 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,
The symbol "enum," was substituted for "socklen_t" to continue.
Syntax error at line 547, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:
Error at line 547, column 2 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h
socklen_t msg_controllen; /* [XSI] ancillary data buffer len */
.1
PCC-S-02201, Encountered the symbol "socklen_t" when expecting one of the follow
ing:
} 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,
The symbol "enum," was substituted for "socklen_t" to continue.
Syntax error at line 583, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:
Error at line 583, column 2 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h
socklen_t cmsg_len; /* [XSI] data byte count, including hdr
*/
.1
PCC-S-02201, Encountered the symbol "socklen_t" when expecting one of the follow
ing:
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,
The symbol "enum," was substituted for "socklen_t" to continue.
Syntax error at line 606, column 2, file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:
Error at line 606, column 2 in file /Applications/Xcode.app/Contents/Developer/P
latforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h
pid_t cmcred_pid; /* PID of sending process */
.1
PCC-S-02201, Encountered the symbol "pid_t" when expecting one of the 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,
Syntax error at line 0, column 0, file lg.pc:
Error at line 0, column 0 in file lg.pc
PCC-S-02201, Encountered the symbol "<eof>" when expecting one of the following:
; : an identifier, end-exec, random_terminal
Error at line 0, column 0 in file lg.pc
PCC-F-02102, Fatal error while doing C preprocessing
操作系统是上面的 Mojave 和 Oracle 客户端版本,我猜错误是链接库或有关头文件的东西,但是在我完成之后我不知道要解决这个问题。任何可以提供帮助的人都非常感激。
ps.最后,我放弃理性地解决这个问题。只是出于这个目的,我几乎通过 3 个步骤解决了它
1:找到一个可以毫无问题地预编译 pro*c 文件的良好环境(docker 是一个不错的选择或另一台计算机)。
2pcscfg.cfg
:将包含一堆.h文件
的路径中的所有文件复制到您的计算机。3:轻松将本地 pcscfg.cfg
文件指向复制的.h文件的路径,即可顺利运行proc
command。