background:
By compiling the php-rdkafka source code ( refer to the link ), get the rdkafka.so library, and put rdkafka.so on other machines to run an error.
Error 1:
- phenomenon:
Run the command php -v and the error is as follows:
PHP Warning: PHP Startup: Unable to load dynamic library 'rdkafka.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so (/lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so)), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.2.10 (cli) (built: Dec 31 2020 08:55:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Running php -i | grep rdkafka reports the following error:
PHP Warning: PHP Startup: Unable to load dynamic library 'rdkafka.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so (/lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so)), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
- the reason:
/lib64/libc.so.6: version `GLIBC_2.14' not found
The dependency `GLIBC_2.14' required by the rdkafka.so library is not found.
The main reason is that the PHP version installed on the machine that compiles the rdkafka.so library is inconsistent with the PHP version installed on the machine using the rdkafka.so library, resulting in lack of dependencies.
It is recommended that the PHP version of the compilation environment and the running environment be the same.
- solve:
Keep the PHP version of the compiled rdkafka.so environment consistent with the PHP version of the rdkafka.so environment.
Error 2:
- phenomenon:
Run php -v
Run php -i | grep rdkafka
Run the code php producer.php
php: symbol lookup error: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/rdkafka.so: undefined symbol: zend_object_alloc
- the reason:
rdkafka.so library does not have zend_object_alloc
Mainly because the PHP version supported by the source code for compiling the rdkafka.so library does not correspond.
It is recommended to download and compile the php-rdkafka source code that supports this PHP version.
- solve:
Download the php-rdkafka source code that supports the PHP version and compile rdkafka.so
Download the source address of each version of php-rdkafka: http://pecl.php.net/package/rdkafka
Download the latest version of php-rdkafka source address: https://github.com/arnaud-lb/php-rdkafka