在 macOS 上为 PHP-7.4 编译 firebird 驱动程序的问题

Issues compiling firebird driver for PHP-7.4 on macos

我一直在尝试 install/compile php-firebird 驱动程序 php7.4 在 macOS 上,但到目前为止没有成功。

驱动程序库中有一个未解决的问题,但在帮助方面没有太多进展。 https://github.com/FirebirdSQL/php-firebird/issues/6

到目前为止我这样做了:

  1. 已安装 https://github.com/FirebirdSQL/firebird/releases/download/R2_5_9/FirebirdCS-2.5.9-27139-x86_64.pkg(也尝试使用 firebird 3.x)
  2. 将此存储库克隆到 php-firebird
  3. cd php-firebird
  4. phpize
  5. CPPFLAGS=-I/Library/Frameworks/Firebird.framework/Versions/Current/Headers LDFLAGS=-L/Library/Frameworks/Firebird.framework/Versions/Current/Libraries ./configure
  6. make ...这就是错误开始的地方
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:159:24: warning: equality comparison result unused [-Wunused-comparison]
                        ib_result->stmt_res == NULL;
                        ~~~~~~~~~~~~~~~~~~~~^~~~~~~
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:159:24: note: use '=' to turn this equality comparison into an assignment
                        ib_result->stmt_res == NULL;
                                            ^~
                                            =

/Users/bonovski/Sandbox/php-firebird/ibase_query.c:178:22: warning: equality comparison result unused [-Wunused-comparison]
                ib_query->stmt_res == NULL;
                ~~~~~~~~~~~~~~~~~~~^~~~~~~
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:178:22: note: use '=' to turn this equality comparison into an assignment
                ib_query->stmt_res == NULL;
                                   ^~
                                   =
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:253:22: error: use of undeclared identifier 'blr_bool'
                case blr_bool:
                     ^
/Users/bonovskiSandbox/php-firebird/ibase_query.c:254:34: error: use of undeclared identifier 'SQL_BOOLEAN'
                    a->el_type = SQL_BOOLEAN;
                                 ^
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:598:22: error: use of undeclared identifier 'SQL_BOOLEAN'
                case SQL_BOOLEAN:
                     ^
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:724:25: warning: incompatible pointer types passing 'zend_long *' (aka 'long long *') to parameter of type 'const time_t *' (aka 'const long *')
      [-Wincompatible-pointer-types]
                                        res = php_gmtime_r(&Z_LVAL_P(b_var), &t);
                                                           ^~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/time.h:127:46: note: passing argument to parameter here
struct tm *gmtime_r(const time_t * __restrict, struct tm * __restrict);
                                             ^
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:790:18: error: use of undeclared identifier 'SQL_BOOLEAN'
            case SQL_BOOLEAN:
                 ^
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:795:32: error: use of undeclared identifier 'SQL_BOOLEAN'
                var->sqltype = SQL_BOOLEAN;
                               ^
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:883:18: error: use of undeclared identifier 'SQL_BOOLEAN'
            case SQL_BOOLEAN:
                 ^
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:1386:14: error: use of undeclared identifier 'SQL_BOOLEAN'
        case SQL_BOOLEAN:
             ^
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:1985:18: error: use of undeclared identifier 'SQL_BOOLEAN'
            case SQL_BOOLEAN:
                 ^
/Users/bonovski/Sandbox/php-firebird/ibase_query.c:2012:18: error: use of undeclared identifier 'SQL_BOOLEAN'
            case SQL_BOOLEAN:
                 ^
3 warnings and 9 errors generated.
make: *** [ibase_query.lo] Error 1

关于布尔数据类型的错误 - 在 Firebird 3.0 中引入 - 清楚地表明你的 PHP 库需要 Firebird 3+,但你给它的源是 FB 2.5 或更早版本。

CPPFLAGS=-I/Library/Frameworks/Firebird.framework/Versions/Current/Headers 
LDFLAGS=-L/Library/Frameworks/Firebird.framework/Versions/Current/Libraries 

我认为在您安装 FB 2.5 之后,您提到的 Versions/Current 是作为指向 2.5 源的符号链接创建的。如果您确实安装了 3.0 源 - 然后检查 Versions/Current 符号链接指向的位置,如果需要,将其更改为 3.0 源(ln -s on Linux,在您的 BSD 命令行实用程序上猜测相同)

快速检查可能会在该位置打开 ibase.h 并检查 API 版本声明:现在在我的 Windows 框中,第三行非注释行如下:#define FB_API_VER 21 在安装了 Firebird 2.1.7 的文件夹中的那个文件中。

或者调整 CPPFLAGSLDFLAGS 以及其他变量以指向特定的 3.x 版本源,而不是一些模糊的“默认”或“当前”。

当然,此标记调整仅在您需要将 FB 2.5 源安装为“当前”源以用于 FB 3 源的某些其他目的的情况下才有意义。我不知道 UNIX-likes,但至少在 Windows 上,拥有多个不同甚至相同版本的 Firebird 服务器 installed/running 是微不足道的,有时也很方便。未来的一些读者可能也会遇到这种情况。