首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在mac上使用Oracle预编译器

问如何在mac上使用Oracle预编译器
EN

Stack Overflow用户
提问于 2019-08-12 10:10:49
回答 1查看 239关注 0票数 0

我被困在这里几天了,任何能帮忙的人都很感激。主要问题是如何在mac上使用oracle预编译器。

我已经一步一步地尝试了如下:1.作为Oracle的正式文档,我下载三个文件:

代码语言:javascript
复制
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

代码语言:javascript
复制
brew tap InstantClientTap/instantclient
brew install instantclient-basic
brew install instantclient-sdk
brew install instantclient-sqlplus 

我使用sqlplus连接到我的Oracle服务器,它成功地在docker中运行。

3.但是,由于该工具不提供安装预编译器。所以我下载

然后instantclient-precomp-macos.x64-12.2.0.1.0-2.zip将其解压缩。

4.我有一个文件夹名precomp,它有一个文件夹名admin,在管理中我有两个文件pcbcfg.cfg和pcscfg.cfg,我把precomp文件夹放在/usr/local/lib/中,这是在我的终端中使用proc逗号时提到的:

System default option values taken from:/usr/local/lib/precomp/admin/pcscfg.cfg.

5.另外,我有一个文件夹名sdk,by我已经通过自制安装了sdk,所以我将sdk中的exec文件名proc和procob复制到/usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/lib/sdk/中。

6.然后将包含文件夹中的所有.h文件放入/usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/lib/sdk/include,以防万一,我也将它们复制到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:

代码语言:javascript
复制
#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");

然后是公共proc test.pc,不幸的是出现了许多错误:

代码语言:javascript
复制
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客户端版本,如上面所示,我想这些错误可能是链接库( link )或与头文件有关的内容,但在我做了这些工作之后,我不知道如何解决这个问题。任何能帮忙的人都很感激。

ps.Finally,我放弃了理性地解决这个问题。为了达到这个目的,我几乎可以通过3步1来解决这个问题:找到一个好的环境(docker是一个很好的选择,或者是另一台计算机),这样就可以没有问题地预编译pro*c文件。2:将路径中的所有文件从pcscfg.cfg复制到计算机中,其中包括一堆.h文件。3:轻松地更改本地pcscfg.cfg文件,指向您复制的.h文件的路径,现在您可以顺利地运行proc逗号。

EN

回答 1

Stack Overflow用户

发布于 2019-08-13 20:41:10

麦克也有类似的问题。在Linux上(OracleLinux7.6和gcc 4.8.5)都可以。作为解决办法,我在预编译文件中注释,然后通过'oracle‘预编译并取消注释stdio.h。然后再编译它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57459264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档