Msphpsql: Unable to load dynamic library '/usr/lib/php/20160303/pdo_sqlsrv.so' - /usr/lib/php/20160303/pdo_sqlsrv.so: undefined symbol: php_pdo_register_driver in Unknown on line 0

Created on 4 Apr 2018  Ā·  20Comments  Ā·  Source: microsoft/msphpsql

SQL Server version

Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64) Aug 22 2017 17:04:49 Copyright (C) 2017 Microsoft Corporation Express Edition (64-bit) on Windows 10 Pro 10.0 (Build 16299: )

Client operating system

Ubuntu 16.04

PHP version

PHP 7.1.15

Problem description

I have installed pdo_sqlsrv via sudo pecl install pdo_sqlsrv and added it to php.ini with

echo "extension=/usr/lib/php/20160303/pdo_sqlsrv.so" >> /etc/php/7.1/fpm/php.ini
echo "extension=/usr/lib/php/20160303/pdo_sqlsrv.so" >> /etc/php/7.1/cli/php.ini

php -v returns

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

pdo_sqlsrv also does not show up in phpinfo(). Can anyone help me fix this?

configuration

Most helpful comment

Hi @niheno

For security reasons, since the latest version we have changed to immediate binding, thus affecting how our drivers are loaded. Please remove the lines concerning pdo_sqlsrv.so in your php.ini files and follow the instructions here.

Hope this helps.

All 20 comments

Hi @niheno

For security reasons, since the latest version we have changed to immediate binding, thus affecting how our drivers are loaded. Please remove the lines concerning pdo_sqlsrv.so in your php.ini files and follow the instructions here.

Hope this helps.

Hi @yitam

Thank you very much for taking the time to help! I managed to solve the problem. I followed the instructions but had to do one more thing:

It was neccessary to copy /etc/php/7.1/cli/conf.d/30-pdo_sqlsrv.ini to /etc/php/7.1/fpm/conf.d for pdo_sqlsrv to show up in phpinfo and for my Laravel application to be able to use it.

I am having this exact issue and am still having problems.

I am running on CentOS7 with php 7.1

So i went to the repo and downloaded the .so files and placed them in my php/modules directory but now i get a different error entirely.

PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/php_sqlsrv_71_ts.so' - /usr/lib64/php/modules/php_sqlsrv_71_ts.so: undefined symbol: tsrm_get_ls_cache in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/php_pdo_sqlsrv_71_ts.so' - /usr/lib64/php/modules/php_pdo_sqlsrv_71_ts.so: undefined symbol: executor_globals_id in Unknown on line 0

this is the original error.

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_sqlsrv.so' - /usr/lib64/php/modules/pdo_sqlsrv.so: undefined symbol: php_pdo_register_driver in Unknown on line 0

any help would be appreciated . I cannot get this to work so i can start my laravel development. I have been at this for hours. tried uninstalling everything and reinstalling etc.

@NickGiacopuzzi It looks like the driver you are trying to load is the thread safe version (it has a _ts in the name instead of _nts). If you installed PHP using your package manager, you have a non-thread safe version of PHP and you need php_sqlsrv_71_nts.so instead. (The nts version of the driver is packaged along with the ts version.)

Using the non-thread safe version will not fix the original error however, because the original error occurs when PHP tries to load pdo_sqlsrv before pdo itself. Full instructions for loading the pdo and pdo_sqlsrv extensions are available here.

Whoops i totally had the wrong ones. I fixed that. However I have the apppropriate INI files. my sqlsrv ini is 30_ and the sglsrvpdo one is 20_ per the documentation. The plain pdo one does not have a numerical prefix.

I have thread safe php directory as well that has the ts so's in them to make sure.

I am not sure what else I am missing.

I use nginx, but ive restarted it and php-fpm.

That did it. i renamed everything i got the numbering scheme wrong. base pdo is now 10- , sglsrv is 20- and pdo_slqsrv is 30-.... runphp -v now and no issues! Thank you for your help!

The little things haha!

Exists an error on Tar.php when sudo pecl install sqlsrv && sudo pecl install pdo_sqlsrv must be executed. Fixed on 1:1.10.5+submodules+notgz-1+ubuntu+deb.sury.org+1

@yitam The link provided still references using pdo_sqlsrv.so for the ini files. I'm struggling through this using Ubuntu18 and trying to figure out the best course of action.

@xmas I'm not sure which link you meant, but please check our latest instructions.

@xmas my oversight. I didn't realize you mentioned Ubuntu 18. You'll have to wait for the new ODBC driver. Please see issue #749 for details.

@yitam do the Ubuntu17 drivers work on 18? (sqlcmd seems to work ok) or should I use 17 for now?

Just so you know @xmas, ODBC driver 17.1 for Ubuntu 17 won't work on Ubuntu 18. Please wait for ODBC driver 17.2

Can someone explain what this command is doing? (from the website linked above: https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-2017#installing-the-drivers-on-ubuntu-1604-and-1710)

echo extension=pdo_sqlsrv.so >>php --ini | grep "Scan for additional .ini files" | sed -e "s|.:\s||"/30-pdo_sqlsrv.ini

It's not immediately clear where the pdo_sqlsrv.ini file is going to be placed?

Hi @robjbrain, please read this question in our FAQ

I am having this exact issue and am still having problems too.

I am running on CentOS7 with php 7.2
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlsrv' (tried: /usr/lib64/php/modules/pdo_sqlsrv (/usr/lib64/php/modules/pdo_sqlsrv: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo_sqlsrv.so (/usr/lib64/php/modules/pdo_sqlsrv.so: undefined symbol: php_pdo_register_driver)) in Unknown on line 0
help me!Thank you!

Download the appropriate ".so" files and place them in your php/modules
folder.

Make sure you have the correct ones for the version of PHP you are using.
Set the ini files up appropriately.

Just did this a few hrs ago. Do not go to php 7.3 ...7.2 has the only
stable pdo sqlsrv extensions

On Thu, Jan 10, 2019, 20:02 nocodeing <[email protected] wrote:

I am having this exact issue and am still having problems too.

I am running on CentOS7 with php 7.2
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlsrv'
(tried: /usr/lib64/php/modules/pdo_sqlsrv
(/usr/lib64/php/modules/pdo_sqlsrv: cannot open shared object file: No such
file or directory), /usr/lib64/php/modules/pdo_sqlsrv.so
(/usr/lib64/php/modules/pdo_sqlsrv.so: undefined symbol:
php_pdo_register_driver)) in Unknown on line 0
help me!Thank you!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/msphpsql/issues/736#issuecomment-453371093,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AXQ8-s2eLegMaA1kVAIJIzAr2Q9yeYk7ks5vCAzhgaJpZM4TGw3A
.

Note:
On Ubuntu 18.04, this error occurs if extension=pdo_sqlsrv.sois loaded before extension=pdo.so.

The proper place to put

extension=sqlsrv.so
extension=pdo_sqlsrv.so

is not in /etc/php/7.2/fpm/php.ini and /etc/php/7.2/cli/php.ini
but in /etc/php/7.2/mods-available/pdo.ini, after extension=pdo.so

Thanks @ststeiger. This is what we have in our current documentation for Ubuntu

Solved this issue for me, I needed to load pdo.so as well as pdo_sqlsrv.so

hi
Solved this issue for me

ubuntu 18.04
php 7.4

I use this command

find  / -name pdo_sqlsrv.so
find / -name sqlsrv.so  

then watched pdo_sqlsrv.so and sqlsrv.so exists in first line of file

/etc/php/7.4/cli/php.ini

next remove pdo_sqlsrv.so and sqlsrv.so in php.ini

Was this page helpful?
0 / 5 - 0 ratings