我正在尝试用以下命令(来自Mac)编译PHP 7.4和PHP 8的pcntl扩展:
wget "https://www.php.net/distributions/php-7.4.0.tar.gz"
tar xvf "php-7.4.0.tar.gz"
cd "php-7.4.0/ext/pcntl/"
phpize
./configure
make
但是,make
命令会在每个版本的PHP>7.3中抛出以下错误:
[-Werror,-Wimplicit-function-declaration]
z_rusage = zend_try_array_init(z_rusage);
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:721:12: warning: incompatible integer to pointer conversion assigning to 'zval *'
(aka 'struct _zval_struct *') from 'int' [-Wint-conversion]
z_rusage = zend_try_array_init(z_rusage);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:745:2: error: implicit declaration of function 'ZEND_TRY_ASSIGN_REF_LONG' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
ZEND_TRY_ASSIGN_REF_LONG(z_status, status);
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:770:14: error: implicit declaration of function 'zend_try_array_init' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
z_rusage = zend_try_array_init(z_rusage);
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:770:12: warning: incompatible integer to pointer conversion assigning to 'zval *'
(aka 'struct _zval_struct *') from 'int' [-Wint-conversion]
z_rusage = zend_try_array_init(z_rusage);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:795:2: error: implicit declaration of function 'ZEND_TRY_ASSIGN_REF_LONG' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
ZEND_TRY_ASSIGN_REF_LONG(z_status, status);
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:979:9: error: implicit declaration of function 'try_convert_to_string' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
if (!try_convert_to_string(element)) {
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:979:9: note: did you mean '_convert_to_string'?
/usr/local/Cellar/php/7.3.11/include/php/Zend/zend_operators.h:249:29: note: '_convert_to_string' declared here
ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op);
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:1010:9: error: implicit declaration of function 'try_convert_to_string' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
if (!try_convert_to_string(element)) {
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:1197:17: error: implicit declaration of function 'zend_try_array_init' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
user_oldset = zend_try_array_init(user_oldset);
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:1197:15: warning: incompatible integer to pointer conversion assigning to 'zval *'
(aka 'struct _zval_struct *') from 'int' [-Wint-conversion]
user_oldset = zend_try_array_init(user_oldset);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:1295:18: error: implicit declaration of function 'zend_try_array_init' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
user_siginfo = zend_try_array_init(user_siginfo);
^
/Users/jrquick/development/encounting/php-extension-library/php-7.4.10/ext/pcntl/pcntl.c:1295:16: warning: incompatible integer to pointer conversion assigning to 'zval *'
(aka 'struct _zval_struct *') from 'int' [-Wint-conversion]
user_siginfo = zend_try_array_init(user_siginfo);
我如何解决这个错误或获得编译版本的pcntl.so?
下载最新的MAMP版本(包括PHP 7.4.10和PHP 8)
然后改成./configure
:
- PHP 7.4。*:
./configure --with-php-config=/Applications/MAMP/bin/php/php7.4.12/bin/php-config
- PHP 8。*:
--with-php-config=/Applications/MAMP/bin/php/php8.0.0/bin/php-config
之后,我的make
命令成功运行并生成了预期的pcntl.so
文件。
完整的命令:
wget "https://www.php.net/distributions/php-7.4.0.tar.gz"
tar xvf "php-7.4.0.tar.gz"
cd "php-7.4.0/ext/pcntl/"
phpize
./configure --with-php-config=/Applications/MAMP/bin/php/php7.4.12/bin/php-config
make