c - 如何在Mac上使用Oracle预编译器

标签 c oracle macos proc precompiler

我被困在这里几天了,任何可以帮助的人都会感激不尽。 主要问题是关于在mac上使用oracle预编译器。

我已经尝试过这样的步骤: 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.但是,由于该工具不提供安装预编译器。 所以我下载
instantclient-precomp-macos.x64-12.2.0.1.0-2.zip 然后解压它。

4.我有一个名为 precomp 的文件夹,其中有一个文件夹名称 admin ,在管理中我有两个文件 pcbcfg.cfg 和 pcscfg.cfg ,我将 precomp 文件夹放入/usr/local/lib/中,其中提到了我在终端中使用 proc commond,如下所示:

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

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

6.然后我将include文件夹中的所有.h文件放入/usr/local/Cellar/instantclient-sdk/18.1.0.0.0-2/lib/sdk/include 为了以防万一,我还将它们复制到 usr/local/include 中。

7.我将 pcscfg.cfg 中的行更改如下: ojit_代码

这就是我所做的一切。

所以我只写一个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 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),不幸的是出现了很多错误:

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:找到一个好的环境(docker是一个不错的选择或另一台计算机),可以毫无问题地预编译pro*c文件。 2:将proc test.pc路径下的所有文件(包括一堆.h文件)复制到您的计算机中。 3:轻松将本地pcscfg.cfg文件指向您复制的.h文件的路径,现在您可以顺利运行pcscfg.cfg commond了。

最佳答案

Mac 也有类似问题。在 Linux 上(带有 gcc 4.8.5 的 Oracle Linux 7.6)一切正常。作为解决方法,我通过“oracle proc”进行注释然后预编译,并取消预编译文件中 stdio.h 的注释。之后编译它。

关于c - 如何在Mac上使用Oracle预编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57459264/

相关文章:

C读取文件内容到字符串数组中

c - 如何获取陷入无限循环的 C 程序的代码覆盖率信息?

c - 如何找到float,double,long double的最大值

oracle - PL/SQL嵌套表中STORE AS的含义

.net - OracleConnections 会超时吗?如果不是,为什么我的 Oracle session (在 v$session 中)消失了?

ios - 在 SWIFT 4 中将文本字段限制为仅正整数

c - 基于隐式矢量化的 HPC 编程语言

sql - 如何包含在某一天没有任何意义的值 (APEX)

css - 连接到外部显示器时滚动条的行为会发生变化

macos - 使用 Swift 实现/注册 OS X 服务