Skip to content
Advertisement

How to compile pcntl for PHP 7.4 and above?

I am attempting to compile the pcntl extension for PHP 7.4 and PHP 8 with the following commands (from Mac):

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

However, the make command is throwing the following error for every version of 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);

How do I get around this error or get a compiled version of pcntl.so?

This same process works for PHP 4 to PHP 7.3

Advertisement

Answer

Download the latest MAMP version (which includes PHP 7.4.10 and PHP 8).

Then changed ./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

Afterwards my make command successful ran and generated the expected pcntl.so file.

Full command:

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
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement