PHP: Relocation error



Error

***All Wordpress pages are seems to be dislocated.

# cat /usr/local/apache/logs/error_logs  showing the following error.

php: symbol zlibVersion , version libmysqlclient_16 not defined in in file libmysqlclient.so.16 with link time reference. Instead php: relocation error: php: symbol zlibVersion the error could be php: relocation error: php: symbol crc32.


# php index.php
 
php: relocation error: php: symbol deflateInit2_, version libmysqlclient_16 not defined in file libmysqlclient.so.16 with link time reference

This is an example and the issue could happen with any shared library not only with libmysqlclient.so .               

                                  As per the error message the library version is not matching so we have to check the shared library dependencies. This can be done with tool called ‘ldd’ which prints the shared library dependencies. In this case we will check PHP for “libmysqlclient” so the command should be like this:


# ldd /usr/bin/php | grep libmysqlclient

 The output should be similar to this one:

 libmysqlclient.so.16 => /usr/lib64/mysql/libmysqlclient.so.16 (0x00000034c6000000)


Let’s check the file:  


# ls -la /usr/lib64/mysql/libmysqlclient.so.16

 In my case this is a symbolic link to the library in the same folder:

 lrwxrwxrwx 1 root root 28 Sep 29 17:09 /usr/lib64/mysql/libmysqlclient.so.16 -> libmysqlclient.so.16.0.0*

 Now let’s check if this file exist in another place.

 # locate libmysqlclient.so.16.0.0

My output is as follows:

/usr/lib64/libmysqlclient.so.16.0.0
/usr/lib64/mysql/libmysqlclient.so.16.0.0

So there are two libraries, and now we have to check where is the missing symbol – for example zlibVersion. For that will use ‘nm’ command lists symbols from object files. Let’s try the current linked file:
   
# nm /usr/lib64/mysql/libmysqlclient.so.16.0.0 | grep zlibVersion

The output is:

 nm: libmysqlclient.so.16.0.0: no symbols

So it seams there are no symbols in this library.
With the other file:  

# nm /usr/lib64/libmysqlclient.so.16.0.0 | grep zlibVersion

The output is:

 00000034c60d64b0 T zlibVersion

Which seams better.

Now I will just remote the current link: 

# rm -f /usr/lib64/mysql/libmysqlclient.so.16


And will create a new one with the library that contains the symbol: 

# ln -s /usr/lib64/libmysqlclient.so.16.0.0 /usr/lib64/mysql/libmysqlclient.so.16



This should resolve the case, and the php: symbol zlibVersion , version libmysqlclient_16 not defined in in file libmysqlclient.so.16 with link time reference error was solved.

This entry was posted by Arun Ghosh. Bookmark the permalink.

2 thoughts on “PHP: Relocation error”