Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after add extension=ds.so to php.ini #2

Open
akondas opened this issue Feb 9, 2016 · 40 comments
Open

Error after add extension=ds.so to php.ini #2

akondas opened this issue Feb 9, 2016 · 40 comments
Labels

Comments

@akondas
Copy link

akondas commented Feb 9, 2016

If i run command

 php -d extension=ds.so some_file.php

Then Ds extension works ok. But when i want add this line to php.ini:

extension=ds.so

Then php throw error:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/ds.so'
 - /usr/lib/php/20151012/ds.so: undefined symbol: php_json_serializable_ce in Unknown on line 0

My PHP version:
PHP 7.0.3 on Ubuntu 14.04

@rtheunissen
Copy link
Member

There is currently a hard dependency on the json extension, which is a bug because it shouldn't try to implement JsonSerializable if the json extension is not loaded.

Try enabling the json extension, or specifying ds.so after json is already enabled.

@akondas
Copy link
Author

akondas commented Feb 9, 2016

@rtheunissen thanks for the quick response. Unfortunately json extension is allready loaded:

Module 'json' already loaded

I check in get_loaded_extensions and json exist. Should i add something else to php.ini ?

@rtheunissen
Copy link
Member

What's your output for php -m?

@rtheunissen
Copy link
Member

I think it's just a loading order issue, potentially more than one .ini

What's your output for php -i | grep ini?

@akondas
Copy link
Author

akondas commented Feb 9, 2016

@rtheunissen ok, json extension was loaded in additional ini file (conf.d). To fix this problem i create new file (for example 30-ds.ini) with content extension=ds.so and put it in /etc/php/7.0/fpm/conf.d. Now ds extension is load as last:

Additional .ini files parsed => /etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/20-curl.ini,
/etc/php/7.0/cli/conf.d/20-gd.ini,
/etc/php/7.0/cli/conf.d/20-intl.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/cli/conf.d/20-pdo_pgsql.ini,
/etc/php/7.0/cli/conf.d/20-pgsql.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/30-ds.ini

Thanks for help 👍

@rtheunissen
Copy link
Member

@nikic I'm facing issue again. Wouldn't this have been fixed in #34 ?

@nikic
Copy link
Contributor

nikic commented Aug 7, 2016

@rtheunissen #34 fixed the loading order issue for static builds. I guess to fix it for so's we should add

PHP_ADD_EXTENSION_DEP(ds, spl)
PHP_ADD_EXTENSION_DEP(ds, json)

to the config.m4.

@nikic
Copy link
Contributor

nikic commented Aug 7, 2016

The w32 variant is ADD_EXTENSION_DEP('ds', 'spl') etc.

@rtheunissen
Copy link
Member

rtheunissen commented Aug 7, 2016

@nikic attempted to fix this in c2def79, rebuilt, still getting undefined symbol: php_json_serializable_ce. Am I missing something in the m4?

@yybalam
Copy link

yybalam commented Aug 10, 2016

Hello. I'm facing this issue too.
At moment I do what @itcraftsmanpl say. I think at least that solution must be documented at readme. I spend an hour before think in search on closed issues for an answer. 😅

But the extension is awesome. Thanks you guys. 😄

@rtheunissen rtheunissen reopened this Aug 10, 2016
@rtheunissen
Copy link
Member

rtheunissen commented Aug 10, 2016

Seems like the only solution is to not add ds.so directly to the main php.ini but to create a new one with a higher alphabetic ranking like @itcraftsmanpl did. This used to be part of the readme.

What's interesting here is that I'm only seeing this issue when I'm using a release build of PHP, ie. when I'm not building PHP myself. When I use phpbrew to build and install, adding to the main php.ini works just fine. I'm guessing static build vs dynamic?

@rtheunissen rtheunissen added Bug and removed PECL labels Aug 10, 2016
@rtheunissen
Copy link
Member

I've added a note in README.md, not much else that can be done.

@kurt-krueckeberg
Copy link

kurt-krueckeberg commented Oct 17, 2016

I was getting the same Unable to load dynamic library ... undefined symbol: php_json_serializable_ce issue as @itcraftsmanpl on Linux Mint, regardless of whether I installed using pecl install ds or did git clone and built the code. Changing /etc/php/7.0/mods-available/ds.ini to be:

; configuration for php ds module
; priority=30
 extension=ds.so

and then doing

 $ sudo phpenmod ds

worked, but only after I manually removed all the 20-ds.ini symbolic links. Thanks so much for this extension!

@castarco
Copy link

castarco commented Oct 20, 2016

I'm facing this issue too :( . I've used the trick of naming the file 30-ds.ini (and ensured that there is not any 20-ds.ini file anywhere), but the problem is happening anyway.

I'm working with PHP7.0, and Ubuntu 16.04. I've installed the extension through PECL. And.. the JSON extension is also installed and loaded.

@kurt-krueckeberg
Copy link

Well, I found that even though I edit /etc/php/7.0/mods-available/ds.ini to look like:

; configuration for php ds module
; priority=30
extension=ds.so

And even though I first did

  $ sudo phpdismod ds

This did not remove the 20-ds.ini symbolic links

$ cd /etc/php/7.0/
$ find . -name "*ds.ini"
./apache2/conf.d/20-ds.ini
./fpm/conf.d/20-ds.ini
./mods-available/ds.ini
./cli/conf.d/20-ds.ini
./cli/conf.d/30-ds.ini

So that after I edited /etc/php/7.0/mods-available/ds.ini to be:

; configuration for php ds module
; priority=30
extension=ds.so

instead of

; configuration for php ds module
; priority=20
 extension=ds.so

and even after I did

 $ sudo phpdismod ds

before doing

$ sudo phpenmod ds

The old 20-ds.ini symbolic links were still present, and I had to manually remove them by hand. Then the error message went away,

@kurt-krueckeberg
Copy link

Well, I found that even though I edit /etc/php/7.0/mods-available/ds.ini
to look like:

; configuration for php ds module
; priority=30
extension=ds.so

And even though I first did

$ sudo phpdismod ds

This did not remove the 20-ds.ini symbolic links

$ cd /etc/php/7.0/
$ find . -name "*ds.ini"

./apache2/conf.d/20-ds.ini
./fpm/conf.d/20-ds.ini
./mods-available/ds.ini
./cli/conf.d/20-ds.ini
./cli/conf.d/30-ds.ini

So that after I edited /etc/php/7.0/mods-available/ds.ini to be:

; configuration for php ds module
; priority=30
extension=ds.so

instead of

; configuration for php ds module
; priority=20
extension=ds.so

and eve after I did

$ sudo phpdismod ds

before doing

$ sudo phpenmod ds

The old 2-ds.ini symbolic links were still present, and I had to
manually remove them by hand.

This showed that there were both 20-ds.ini and 30-ds.ini symbolic links.

On 10/20/2016 08:51 AM, Andreu Correa Casablanca wrote:

I'm facing this issue too :( . I've used the trick of naming the file
30-ds.ini (and ensuring that there is not 20-ds.ini file), but the
problem is happening anyway.

I'm working with PHP7.0, and Ubuntu 16.04. I've installed the
extension through PECL.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAH9yoJpZTInh6QdU3t-twoMjFt8VV0cks5q12PagaJpZM4HWSF0.

@yybalam
Copy link

yybalam commented Oct 20, 2016

@castarco After ensure that you put a 30-ds.ini also check to remove (or comment) the extension=ds.so from your php.ini file.

@castarco
Copy link

castarco commented Oct 20, 2016

@yybalam I haven't any line like this one in my php.ini file. I've looked for it with grep and the vim's search feature.

P.D.: I'm working only with the PHP CLI, I'm not using (nor installed) PHP-FPM nor phpmod for Apache.

@kurt-krueckeberg
Copy link

Do
php -m
to see which extensions are active
On 10/20/2016 10:45 AM, Andreu Correa Casablanca wrote:

@yybalam https://github.com/yybalam I haven't any line like this one
in my php.ini file. I've looked for it with |grep| and the |vim|'s
search feature.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAH9yrlyNErW-XPzucvSdI3r63Pg0g38ks5q135ygaJpZM4HWSF0.

@castarco
Copy link

@kkruecke I've did it before. This is the result:

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
intl
json
libxml
mbstring
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib

[Zend Modules]
Xdebug
Zend OPcache

@rtheunissen
Copy link
Member

@castarco

I haven't any line like this one in my php.ini file

Are you using php -d extension=ds.so then?

@castarco
Copy link

Hi @rtheunissen , yes. I'm using this option, and sometimes I use dynamic loading, with a call to dl, but this last workaround is a little bit dirty since it's a very insecure method.

@kurt-krueckeberg
Copy link

I am running Linux Mint 18. Neither Ubuntu nor Mint 18 does use one
single php.ini. Instead Linux Mint and Ubuntu have structured the
installation of php extensions to use a separate .ini files that reside
in /etc/php/7.0/mods-available/. When you enable an extension using
"phpenmod", it creates a symbolic links to the mods-available file:

$ sudo phpenmod ds
$ find /etc/php/7.0 -name "*ds.ini"

./apache2/conf.d/30-ds.ini
./fpm/conf.d/30-ds.ini
./mods-available/ds.ini
./cli/conf.d/30-ds.ini

On 10/20/2016 08:43 PM, Rudi Theunissen wrote:

@castarco https://github.com/castarco

I haven't any line like this one in my php.ini file

Are you using |php -d extension=ds.so| then?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAH9yq08ZfWIbZdrM6QtUPyioO5vQb0Fks5q2AqXgaJpZM4HWSF0.

@jdestefx
Copy link

I ran into this problem on centos7 / php7.

I had to make an INI file called z_ds.ini and not 30-ds.ini like suggested earlier in the thread. In centos7/php7, the /etc/php.d/ files do not have numeric prefixes for easy ordering, hence why I had to prefix with z_.

Good luck.

@rtheunissen
Copy link
Member

This is so infuriating, how are other extensions not also running into this problem / how is this still a thing? Thanks for all the feedback here everyone, I'm going to link the readme directly to this issue.

@rtheunissen rtheunissen reopened this Nov 16, 2016
@derickr
Copy link

derickr commented Dec 1, 2016

@rtheunissen - Other extensions are also suffering from this. The issue is with distribution's PHPs not doing the standard PHP thing. I have written an explanation at https://derickrethans.nl/undefined-symbol.html about the how and why.

@grizzlylab
Copy link
Contributor

I had this problem too and I was a little stupid, actually when removing dirty symbolic links, do not forget to remove it for CLI too and not only for Apache/Nginx.

I had the error "php_json_serializable_ce" (described sooner in this topic) and I solved it like this:

cd /etc/php/7.1/apache2/conf.d
rm 20-ds.ini

cd /etc/php/7.1/**cli**/conf.d
rm 20-ds.ini

@lsrocha
Copy link

lsrocha commented Jun 20, 2017

I'm using Fedora 25 (PHP 7.0.20) and I have had the same problem. Just creating a new config file /etc/php.d/50-ds.ini, as teached on @derickr post, worked perfectly.

Inside the file, just extension=ds.so is needed.

@miradnan
Copy link

I am using ubuntu and having the same problem with PHP 7.0.18

@rtheunissen
Copy link
Member

This is not a bug, just the nature of how some distributions handle their INI loading.

rtheunissen added a commit that referenced this issue Feb 17, 2019
@charlie39
Copy link

charlie39 commented Mar 12, 2019

On Ubuntu 18.04 and faced this issue.
Same as the OP described. Created an ini file in mods-available , did sudo phpenmod ds. After that I can see the 30-ds.ini file from phpinfo() but however , it does not show up in get_loaded_entensions() .
Neither it show up in PHP -m . Though I can use the temporary hack ( php -d extension=ds.so) .
Any suggestions?

glensc added a commit to pld-linux/php-pecl-ds that referenced this issue Mar 21, 2019
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php71/ds.so' - /usr/lib64/php71/ds.so: undefined symbol: php_json_serializable_ce in Unknown on line 0

- php-ds/ext-ds#2
- php-ds/ext-ds#34
@rtheunissen rtheunissen reopened this May 12, 2019
@rtheunissen
Copy link
Member

This is currently the best resource related to this problem: https://derickrethans.nl/undefined-symbol.html

I have re-opened it because I am now facing this issue myself. 😂

@glensc
Copy link
Contributor

glensc commented May 12, 2019

I created a patch that uses external void * symbol for linking and associates to the real symbol at MINIT:

but somewhy that did not work out somehow, need to work more on that, so i also went with the easier approach, changing load order of modules :)

@chippyash
Copy link

Well, it appears this problem hasn't disappeared in 2020 either, at least not under Windows:

  • running Win 10 + WSL
  • under WSL, install the extension - no problem
  • in Win, go to pecl, grab the dll, (V1.2.9) put it in PHP_ROOT/ext directory and add extension=ds as instructed in a hundred places
  • in win powershell, php -v gives the dreaded 'Unable to load dynamic library 'ds' ' error. Even after a reboot - just in case - it is win after all!
  • double check, make sure I have correct extension and architecture (TS - x64), yes I do (been through this loop a few times with other extensions!)
  • read this and other threads but cannot find extension=json in php.ini (there are no separate ini files in win) 'cus I assume that PHP (V7.2.21) is built with json extension already, like any sane distribution these days (no assumption really as everything else Json just works.)

I have developers using *nix and doze, so need this stuff working on both platforms. Ah you say, just include the composer package. I need to put explicit compliance to ext-ds in composer requires for performance reasons. Ergo it baulks if it can't find the extension.

So - any suggestions on how to fix this in 'Doze 10?

@rtheunissen
Copy link
Member

@chippyash extension=ds.dll or extension=php_ds.dll isn't it?

@chippyash
Copy link

@rtheunissen On windows 10 you can specify

  • extension=ds
  • extension=php_ds.dll
    Both should work. (the former pattern is how all other extensions are loaded in my instance.)

I'm wondering if it is a similar problem to the AMQP issue. That fails unless you have 'rabbitmq.4.dll' in PHP_ROOT. Does that spark anything with anyone?

@botjaeger
Copy link

encountered this issue too, fixed it by creating a symlink called /etc/php/7.3/cli/conf.d/25-ds.ini
so the /etc/php/7.3/cli/conf.d/20-json.ini will load first

@pbrilius
Copy link

On my laptop, Ubuntu LTS changing ds.ini to 25-ds.ini didn't do the trick, sadly.

@fd6130
Copy link

fd6130 commented Apr 9, 2021

You can sudo apt install php7.4-ds instead of manually creating or linking the extension.

@lizhaoyao
Copy link

My code is

<?php
$vector = new \Ds\Vector();

$vector->push('a');
$vector->push('b', 'c');

$vector[] = 'd';

var_dump($vector);

?>

I got this error message

PHP Warning:  PHP Startup: Unable to load dynamic library 'ds' (tried: /usr/lib/php/20190902/ds (/usr/lib/php/20190902/ds: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/ds.so (/usr/lib/php/20190902/ds.so: undefined symbol: php_json_serializable_ce)) in Unknown on line 0
	PHP Fatal error:  Uncaught Error: Class 'Ds\Vector' not found in vector.php:11
	Stack trace:
	#0 {main}
	  thrown in vector.php on line 11

then I found ds need load after json,so I use the steps to repair it.(I use php7.4 in ubuntu)

sudo cp /etc/php/7.4/mods-available/json.ini /etc/php/7.4/mods-available/ds.ini
sudo gedit /etc/php/7.4/mods-available/ds.ini

edit its content

; configuration for php json module
; priority=30
extension=ds.so

then make a link

sudo ln -s /etc/php/7.4/mods-available/ds.ini /etc/php/7.4/cli/conf.d/30-ds.ini
sudo ln -s /etc/php/7.4/mods-available/ds.ini /etc/php/7.4/apache2/conf.d/30-ds.ini

remove or make a notes from php.ini
;extension=ds
then restart apache2
sudo /etc/init.d/apache2 restart
then run again
it's ok, the result is

object(Ds\Vector)#1 (4) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [2]=>
  string(1) "c"
  [3]=>
  string(1) "d"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests