I have get stuck here few days,anyone who can help is grateful. The main question is about using oracle Precompiler on mac.
I have tried step by step like this: 1.As Oracle official documents,I download three files:
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.then follow steps as mentioned here https://github.com/InstantClientTap/homebrew-instantclient:
brew tap InstantClientTap/instantclient
brew install instantclient-basic
brew install instantclient-sdk
brew install instantclient-sqlplus
I used sqlplus connect to my Oracle server which run in docker successfully.
3.BUT, due to this tool not provide install precompiler.
So I download
instantclient-precomp-macos.x64-12.2.0.1.0-2.zip
then unzip it.
4.I got a folder name precomp which have a folder name admin ,and in the admin I have two files pcbcfg.cfg and pcscfg.cfg, I put the precomp folder into /usr/local/lib/ which mentioned when I use proc
commond in my Terminal like this :
System default option values taken from:/usr/local/lib/precomp/admin/pcscfg.cfg.
5.also, I got a folder name sdk, bcuz I have install sdk by homebrew, so I copy the exec files name proc and procob in the sdk to /usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/lib/sdk/
6.and then I put all the .h files in the include folder to /usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/lib/sdk/include
just in case, I also copy them into usr/local/include
.
7.And I changed the lines in the pcscfg.cfg like this:
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)
that's all I have done.
So I just write a 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");
then commond proc test.pc
, unfortunately there are many errors appeared:
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
the OS is Mojave and Oracle Client version as above,I guess the errors are link lib or something about header files, but I dont have any idea to resolve this after what I have done. Anyone who can help is so grateful.
ps.Finally,I give up to solve this problem rational. Just for the intention, I almost solve it by 3 steps
1:Find a good environment(docker is a good option or another computer) which can precompiled pro*c file without problem.
2:Copy all of files in the path from the pcscfg.cfg
include a bunch of .h files to your computer.
3:Easily change your local pcscfg.cfg
file point to the path of the .h files which you copied, and now you can smoothly run the proc
commond.