msphpsql: PHP 7.2 Unable to load dynamic library - undefined symbol: call_user_function

I am having problems setting up the driver on PHP 7.2. The same procedure (as described in the repro section) was used to set it up on 7.1, which I still use on the same server, which has Plesk and multiple PHP versions installed (although note the below has nothing to do with Plesk).

Driver version or file name

Release Version 5.2.0 (stable)

Client operating system

Ubuntu 16.04.4 LTS

PHP version

7.2

Microsoft ODBC Driver version

Package: msodbcsql17 Version: 17.1.0.1-1

Problem description

The module cannot be loaded, with error: PHP Warning: PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /opt/plesk/php/7.2/lib/php/modules/sqlsrv.so (/opt/plesk/php/7.2/lib/php/modules/sqlsrv.so: undefined symbol: call_user_function), /opt/plesk/php/7.2/lib/php/modules/sqlsrv.so.so (/opt/plesk/php/7.2/lib/php/modules/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Repro code

  1. /opt/plesk/php/7.2/bin/pecl install sqlsrv
  2. Find the compiled extension: find / -name 'sqlsrv.so'
  3. Copy compiled extension to correct dir: cp /usr/lib/php/20151012/sqlsrv.so /opt/plesk/php/7.2/lib/php/modules/
  4. Create .ini (with 75- prefix, so it’s loaded last) echo "extension=sqlsrv.so" > /opt/plesk/php/7.2/etc/php.d/75-sqlsrv.ini
  5. Try running a php command, e.g.:
root@ocelot:~# /opt/plesk/php/7.2/bin/php -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /opt/plesk/php/7.2/lib/php/modules/sqlsrv.so (/opt/plesk/php/7.2/lib/php/modules/sqlsrv.so: undefined symbol: call_user_function), /opt/plesk/php/7.2/lib/php/modules/sqlsrv.so.so (/opt/plesk/php/7.2/lib/php/modules/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.2.5 (cli) (built: Apr 27 2018 10:11:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

Ok, got it. By looking at the output, I realised it’s not using the correct API, like you mentioned before.

root@ocelot:~# /opt/plesk/php/7.2/bin/pecl install sqlsrv
Starting to download sqlsrv-5.2.0.tgz (171,728 bytes)
.....................................done: 171,728 bytes
33 source files, building
running: phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
building in /tmp/pear-build-rootjrBqt7/sqlsrv-5.2.0

However:

root@ocelot:~# /opt/plesk/php/7.2/bin/php -i | grep "PHP API"
PHP API => 20170718

The solution was to install plesk-php72-dev and fix the PECL config, like described here. After reinstalling it already copies it in the correct modules dir. So yes, it’s was probably just a multi-php Plesk specific issue (don’t know if the OS provided one installs the dev package). Thank you for helping out 😃

Thank you that sovled it!! I added extension=pdo.so just above the extension=pdo_sqlsrv.so and it worked!

I also removed all the odbc mssq-tools, some freetds and freetds-dev stuff i had and then reinstalled mssql-tools, unixodbc, unixodbc-dev and msodbcsql17

Solved a similar problem as follows:

pecl config-set php_ini /etc/php/7.2/cli/php.ini
pecl uninstall pdo_sqlsrv
pecl install pdo_sqlsrv

And also put the package apt-get install php7.2-dev Otherwise, an error occurred sh: 1: phpize7.2: not found ERROR: phpize failed

install plesk-php72-dev

Find and put this package failed