Reputation: 317
I'm trying to install swoole on my machine
first :
pecl install swoole
Then i need a php module
cd swoole
phpize
./configure
make
sudo make install
The script create a swoole.so in my folder, so i add it in my php.ini :
extension=/usr/lib/php/20151012/swoole.so
When i try php -v, i'v got:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/swoole.so' (tried: /usr/lib/php/20151012/swoole.so (/usr/lib/php/20151012/swoole.so: undefined symbol: spl_ce_Countable), /usr/lib/php/20170718//usr/lib/php/20151012/swoole.so.so (/usr/lib/php/20170718//usr/lib/php/20151012/swoole.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Dec 7 2018 08:07:08) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.13-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
What is this error : undefined symbol: spl_ce_Countable ?
Thanks a lot.
Upvotes: 2
Views: 2694
Reputation: 59
I had same issue, so please read carefully.
If php modules are loaded from mods-available folder, don't add
extension=swoole.so
manually to php.ini, instead of that you have to add aswoole.ini
file to php mods-available folder.;configuration for php common module ;priority=20 extension=swoole.so
and enable it withsudo phpenmod swoole
What happens is if you add extension=swoole.so manually to php.ini, it connects before all the required extensions. For instance, if you added --enable-sockets and so to swoole installation and the swoole extension loads before sockets extension, it will fail, so after I removed extension=swoole.so from php.ini, added swoole.ini file to php mods-available folder and enabled it with sudo phpenmod swoole swoole is working properly.
Copied from: https://github.com/swoole/swoole-src/issues/3952#issuecomment-782765934
Upvotes: 0
Reputation: 5941
Most of the times, such error is thrown when you try to load an extension which depends upon other extensions which are either not loaded yet or not enabled. Therefore, it is recommended to load it via phpenmod
. Some Linux distributions like Debian or Ubuntu use the PHP mods-available
to load PHP extensions.
You can either create a file manually for extension name like openswoole.ini
in following directory /etc/php/<PHP_VERSION>/mods-available
with following data
; Configuration for Open Swoole
; priority=30
extension=openswoole
Or you can run below commands, remember to change <PHP_VERSION>
to your php version
sudo bash -c "cat > /etc/php/<PHP_VERSION>/mods-available/openswoole.ini << EOF
; Configuration for Open Swoole
; priority=30
extension=openswoole
EOF"
sudo phpenmod -s cli openswoole
php -m | grep openswoole
Upvotes: 3
Reputation: 317
I had several php versions installed on my machine. But version 7.2 did not have a php-config file.
sudo apt-get install php7.2-dev
this solved my problem
Thanks to @Álvaro González
Upvotes: 1