Мне нужно расширение pdo_odbc.so для php 5.6.24, работающее на macOS High Sierra.
Веб-сервер с PHP работает отлично. Но без расширения PDO_ODBC пока.
Поэтому я должен был создать .so файл ….
Я установил brew (версия 1.8.0), autoconf (версия 2.69), unixodbc (версия 2.3.7) и загрузил ресурсы php-5.6.24.
После извлечения исходников php я перешел в каталог php-5.6.24 / ext / pdo_odbc и выполнил:
phpize
./configure --with-pdo-odbc=unixODBC
Настройка завершена с сообщением «config.status: создание config.h». Отлично!
Следующий шаг:
make
Make приносит много предупреждений и ошибок, которые я не понимаю:
admins-Mac-mini:pdo_odbc admin$ make
/bin/sh /Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/libtool --mode=compile cc -I/usr/include/php/ext -I/usr/local/include -DPDO_ODBC_TYPE=\"unixODBC\" -I. -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc -DPHP_ATOM_INC -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/include -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/main -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/pdo_odbc.c -o pdo_odbc.lo
mkdir .libs
cc -I/usr/include/php/ext -I/usr/local/include -DPDO_ODBC_TYPE=\"unixODBC\" -I. -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc -DPHP_ATOM_INC -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/include -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/main -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/pdo_odbc.c -fno-common -DPIC -o .libs/pdo_odbc.o
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/pdo_odbc.c:135:63: warning: cast to 'void *' from smaller integer type 'SQLUINTEGER' (aka 'unsigned int')
[-Wint-to-void-pointer-cast]
SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)pdo_odbc_pool_on, 0);
^
1 warning generated.
/bin/sh /Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/libtool --mode=compile cc -I/usr/include/php/ext -I/usr/local/include -DPDO_ODBC_TYPE=\"unixODBC\" -I. -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc -DPHP_ATOM_INC -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/include -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/main -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c -o odbc_driver.lo
cc -I/usr/include/php/ext -I/usr/local/include -DPDO_ODBC_TYPE=\"unixODBC\" -I. -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc -DPHP_ATOM_INC -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/include -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/main -I/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c -fno-common -DPIC -o .libs/odbc_driver.o
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:52:39: error: too many arguments to function call, expected 2, have 3
add_next_index_string(info, message, 0);
~~~~~~~~~~~~~~~~~~~~~ ^
/usr/include/php/Zend/zend_API.h:437:1: note: 'add_next_index_string' declared here
ZEND_API int add_next_index_string(zval *arg, const char *str);
^
/usr/include/php/main/php_config.h:6:19: note: expanded from macro 'ZEND_API'
# define ZEND_API __attribute__ ((visibility("default")))
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:53:49: error: too many arguments to function call, expected 2, have 3
add_next_index_string(info, einfo->last_state, 1);
~~~~~~~~~~~~~~~~~~~~~ ^
/usr/include/php/Zend/zend_API.h:437:1: note: 'add_next_index_string' declared here
ZEND_API int add_next_index_string(zval *arg, const char *str);
^
/usr/include/php/main/php_config.h:6:19: note: expanded from macro 'ZEND_API'
# define ZEND_API __attribute__ ((visibility("default")))
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:92:41: warning: passing 'char [6]' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
rc = SQLGetDiagRec(htype, eh, recno++, einfo->last_state, &einfo->last_error,
^~~~~~~~~~~~~~~~~
/usr/local/include/sql.h:727:70: note: passing argument to parameter 'Sqlstate' here
SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:93:4: warning: passing 'char [512]' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
einfo->last_err_msg, sizeof(einfo->last_err_msg)-1, &errmsgsize);
^~~~~~~~~~~~~~~~~~~
/usr/local/include/sql.h:728:72: note: passing argument to parameter 'MessageText' here
SQLINTEGER *NativeError, SQLCHAR *MessageText,
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:120:42: warning: passing 'char [6]' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
rc = SQLGetDiagRec(htype, eh, recno++, discard_state, &code,
^~~~~~~~~~~~~
/usr/local/include/sql.h:727:70: note: passing argument to parameter 'Sqlstate' here
SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:121:5: warning: passing 'char [1024]' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
discard_buf, sizeof(discard_buf)-1, &errmsgsize);
^~~~~~~~~~~
/usr/local/include/sql.h:728:72: note: passing argument to parameter 'MessageText' here
SQLINTEGER *NativeError, SQLCHAR *MessageText,
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:161:59: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *'
(aka 'unsigned long *') [-Wincompatible-pointer-types]
ret = pdo_parse_params(stmt, (char*)sql, sql_len, &nsql, &nsql_len TSRMLS_CC);
^~~~~~~~~
/usr/include/php/ext/pdo/php_pdo_driver.h:679:27: note: passing argument to parameter 'outquery_len' here
char **outquery, size_t *outquery_len);
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:197:27: warning: passing 'char *' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
rc = SQLPrepare(S->stmt, (char*)sql, SQL_NTS);
^~~~~~~~~~
/usr/local/include/sql.h:762:44: note: passing argument to parameter 'StatementText' here
SQLCHAR *StatementText, SQLINTEGER TextLength);
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:236:27: warning: passing 'char *' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
rc = SQLExecDirect(stmt, (char *)sql, sql_len);
^~~~~~~~~~~
/usr/local/include/sql.h:668:47: note: passing argument to parameter 'StatementText' here
SQLCHAR *StatementText, SQLINTEGER TextLength);
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:359:44: error: too many arguments provided to function-like macro invocation
ZVAL_STRING(val, "ODBC-" PDO_ODBC_TYPE, 1);
^
/usr/include/php/Zend/zend_API.h:583:9: note: macro 'ZVAL_STRING' defined here
#define ZVAL_STRING(z, s) do { \
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:359:4: error: use of undeclared identifier 'ZVAL_STRING'
ZVAL_STRING(val, "ODBC-" PDO_ODBC_TYPE, 1);
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:378:2: warning: incompatible pointer types initializing 'pdo_dbh_prepare_func' (aka 'int (*)(struct _pdo_dbh_t *,
const char *, unsigned long, struct _pdo_stmt_t *, struct _zval_struct *)') with an expression of type 'int (pdo_dbh_t *, const char *, long, pdo_stmt_t *, zval *)'
(aka 'int (struct _pdo_dbh_t *, const char *, long, struct _pdo_stmt_t *, struct _zval_struct *)') [-Wincompatible-pointer-types]
odbc_handle_preparer,
^~~~~~~~~~~~~~~~~~~~
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:379:2: warning: incompatible pointer types initializing 'pdo_dbh_do_func' (aka 'long long (*)(struct _pdo_dbh_t
*, const char *, unsigned long)') with an expression of type 'long (pdo_dbh_t *, const char *, long)' (aka 'long (struct _pdo_dbh_t *, const char *, long)')
[-Wincompatible-pointer-types]
odbc_handle_doer,
^~~~~~~~~~~~~~~~
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:380:2: warning: incompatible pointer types initializing 'pdo_dbh_quote_func' (aka 'int (*)(struct _pdo_dbh_t *,
const char *, unsigned long, char **, unsigned long *, enum pdo_param_type)') with an expression of type 'int (pdo_dbh_t *, const char *, int, char **, int *, enum
pdo_param_type)' (aka 'int (struct _pdo_dbh_t *, const char *, int, char **, int *, enum pdo_param_type)') [-Wincompatible-pointer-types]
odbc_handle_quoter,
^~~~~~~~~~~~~~~~~~
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:384:2: warning: incompatible pointer types initializing 'pdo_dbh_set_attr_func' (aka 'int (*)(struct _pdo_dbh_t
*, long long, struct _zval_struct *)') with an expression of type 'int (pdo_dbh_t *, long, zval *)' (aka 'int (struct _pdo_dbh_t *, long, struct _zval_struct *)')
[-Wincompatible-pointer-types]
odbc_handle_set_attr,
^~~~~~~~~~~~~~~~~~~~
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:387:2: warning: incompatible pointer types initializing 'pdo_dbh_get_attr_func' (aka 'int (*)(struct _pdo_dbh_t
*, long long, struct _zval_struct *)') with an expression of type 'int (pdo_dbh_t *, long, zval *)' (aka 'int (struct _pdo_dbh_t *, long, struct _zval_struct *)')
[-Wincompatible-pointer-types]
odbc_handle_get_attr, /* get attr */
^~~~~~~~~~~~~~~~~~~~
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:412:49: warning: cast to 'void *' from smaller integer type 'SQLUINTEGER' (aka 'unsigned int')
[-Wint-to-void-pointer-cast]
rc = SQLSetEnvAttr(H->env, SQL_ATTR_CP_MATCH, (void*)pdo_odbc_pool_mode, 0);
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:435:51: warning: cast to 'void *' from smaller integer type 'SQLUINTEGER' (aka 'unsigned int')
[-Wint-to-void-pointer-cast]
rc = SQLSetConnectAttr(H->dbc, SQL_ODBC_CURSORS, (void*)cursor_lib, SQL_IS_INTEGER);
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:456:39: warning: passing 'char *' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
rc = SQLDriverConnect(H->dbc, NULL, (char*)dbh->data_source, strlen(dbh->data_source),
^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/sqlext.h:1793:18: note: passing argument to parameter 'szConnStrIn' here
SQLCHAR *szConnStrIn,
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:457:5: warning: passing 'char [1024]' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
dsnbuf, sizeof(dsnbuf)-1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
^~~~~~
/usr/local/include/sqlext.h:1795:24: note: passing argument to parameter 'szConnStrOut' here
SQLCHAR *szConnStrOut,
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:460:27: warning: passing 'char *' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
rc = SQLConnect(H->dbc, (char*)dbh->data_source, SQL_NTS, dbh->username, SQL_NTS, dbh->password, SQL_NTS);
^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/sql.h:633:44: note: passing argument to parameter 'ServerName' here
SQLCHAR *ServerName, SQLSMALLINT NameLength1,
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:460:61: warning: passing 'char *' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
rc = SQLConnect(H->dbc, (char*)dbh->data_source, SQL_NTS, dbh->username, SQL_NTS, dbh->password, SQL_NTS);
^~~~~~~~~~~~~
/usr/local/include/sql.h:634:44: note: passing argument to parameter 'UserName' here
SQLCHAR *UserName, SQLSMALLINT NameLength2,
^
/Users/admin/Downloads/php-5.6.24/ext/pdo_odbc/odbc_driver.c:460:85: warning: passing 'char *' to parameter of type 'SQLCHAR *' (aka 'unsigned char *') converts between
pointers to integer types with different sign [-Wpointer-sign]
rc = SQLConnect(H->dbc, (char*)dbh->data_source, SQL_NTS, dbh->username, SQL_NTS, dbh->password, SQL_NTS);
^~~~~~~~~~~~~
/usr/local/include/sql.h:635:44: note: passing argument to parameter 'Authentication' here
SQLCHAR *Authentication, SQLSMALLINT NameLength3);
^
19 warnings and 4 errors generated.
make: *** [odbc_driver.lo] Error 1
Я пробовал разные версии PHP (в том числе PHP 7 ..).
Я также попробовал другую версию phpize (PHP Api Version 20131106).
Что я упустил?
Задача ещё не решена.
Других решений пока нет …