php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48614 Loading "pdo_sqlite.so" fails: undefined symbol: sqlite3_libversion
Submitted: 2009-06-20 09:58 UTC Modified: 2020-12-22 16:55 UTC
Votes:102
Avg. Score:4.4 ± 0.8
Reproduced:96 of 97 (99.0%)
Same Version:26 (27.1%)
Same OS:23 (24.0%)
From: kaspernj at gmail dot com Assigned:
Status: Wont fix Package: PDO SQLite
PHP Version: 5.3.0RC4 OS: Ubuntu Jaunty
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kaspernj at gmail dot com
New email:
PHP Version: OS:

 

 [2009-06-20 09:58 UTC] kaspernj at gmail dot com
Description:
------------
After succesfully compiling PHP 5.3 RC4 with PDO and PDO-SQLite, I ran a test-script to test all the shared extensions.

When trying to load the PDO-SQLite extension, I get the following error:
Warning: dl(): Unable to load dynamic library '.../pdo_sqlite.so' - .../pdo_sqlite.so: undefined symbol: sqlite3_libversion in ../test.php on line 5

Everything was compiled as shared extensions and loaded through a CLI script with dl().

Reproduce code:
---------------
#!/opt/php53/bin/php
<?php
 dl("gd.so");
 dl("pdo.so");
 dl("pdo_sqlite.so");
 echo("Hejsa\n");
?>

Expected result:
----------------
Hejsa


Actual result:
--------------
Warning: dl(): Unable to load dynamic library '.../pdo_sqlite.so' - .../pdo_sqlite.so: undefined symbol: sqlite3_libversion in ../test.php on line 5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-20 12:20 UTC] pajoye@php.net
Which configure line did you use?
 [2009-06-20 13:19 UTC] kaspernj at gmail dot com
Thank you for responding.

I used the following configure-line:

./configure --with-mysql=shared --with-gd=shared --with-pgsql=shared --enable-pcntl=shared --with-gettext=shared --with-mysqli=shared --with-imap=shared --with-mcrypt=shared --with-kerberos --with-imap-ssl --with-sqlite=shared --enable-sockets=shared --with-pdo-mysql=shared --with-pdo-sqlite=shared --enable-ftp=shared --enable-pdo=shared --with-pdo-pgsql=shared --enable-sockets=shared --enable-cli --disable-cgi --prefix=/opt/php53 --with-ldap=shared --with-pear=shared --disable-debug --with-bz2=shared --with-iconv=shared --with-regex=shared --enable-xml=shared --enable-dom=shared --with-xmlrpc=shared --with-mhash=shared --with-unixODBC=shared,/usr --enable-mbstring=shared --enable-xmlreader=shared --with-sqlite3=shared
 [2009-06-20 16:35 UTC] scottmac@php.net
If you load

sqlite3.so first does it work?
 [2009-06-20 16:41 UTC] kaspernj at gmail dot com
"sqlite3.so" loads fine.

It does not help to load "pdo_sqlite.so" afterwards though - getting the exact same error.

Here is what I did:
#!/opt/php53/bin/php
<?php
	dl("gd.so");
	dl("sqlite3.so");
	dl("pdo.so");
	dl("pdo_sqlite.so");
	echo("Hejsa\n");
?>
 [2009-06-23 07:18 UTC] dominics at gmail dot com
I can reproduce this bug (Debian Lenny) with the following minimal configure line:

./configure --with-zlib --enable-pdo=shared --with-sqlite=shared --with-pdo-sqlite=shared

For now, not building PDO as shared seems to be a workaround.
 [2009-07-09 18:18 UTC] dkepplinger at gmail dot com
I have the same problem with PHP 5.3 on Debian 5.0.2 when loading the pdo_sqlite.so extension in the config file.
 [2009-08-23 00:22 UTC] koubel at volny dot cz
yes, same problem with php 5.3.0 final instalation on debian stable
 [2009-11-11 17:12 UTC] kenashkov at gmail dot com
I'm able to reproduce this with 5.3.1 RC3 on debian 5.
 [2009-11-22 23:37 UTC] i dot galic at brainsware dot org
from pdo_sqlite.la
# Libraries that this one depends upon.
dependency_libs=' -lrt'

from pdo_pgsql.la:
# Libraries that this one depends upon.
dependency_libs=' -lpq'

Makes sense. The obvious fix (or workaround) would be to do:

--with-sqlite=shared,/usr --with-pdo-pgsql=shared,/usr etc..

In Debian, make sure to have libsqlite0-dev and libsqlite3-dev installed
 [2009-11-23 22:48 UTC] koubel at volny dot cz
i dot galic: yes, but if I use bundled sqlite, without /usr in configure, bug is still here. When I use --enable-pdo=shared --with-pdo-sqlite=shared
"configure" and "make" phases are ok, but when I try to use "make test" all tests fails, because warning:
dl(): Unable to load dynamic library '.../pdo_sqlite.so' -
.../pdo_sqlite.so: undefined symbol: sqlite3_libversion

is produced on every test.

So bug is still there (tested php 5.3.1 on Debian Lenny). Using own sqlite is workaround I think.
 [2010-02-02 09:40 UTC] marc dot bennewitz at giata dot de
I have the same problem with suse 10.x 32/64 bit using php 5.3.0/1 stable.

My configure is:
cd "/home/worker/download/php-5.3.1"
./configure \
        --with-apxs2=/usr/local/apache2/bin/apxs \
        --with-mm \
        --with-mysql=shared,/usr/local \
        --with-mysqli=shared,/usr/local/bin/mysql_config \
        --with-sqlite=shared \
        --with-sqlite3=shared \
        --enable-pdo=shared \
        --with-pdo-mysql=shared,/usr/local \
        --with-pdo-sqlite=shared \
        --with-libxml-dir=/usr/local/lib \
        --enable-soap \
        --with-zlib \
        --disable-cgi \
        --with-gd=shared \
        --with-freetype-dir \
        --with-jpeg-dir=/usr/lib \
        --enable-gd-native-ttf \
        --enable-exif \
        --with-xsl \
        --with-mcrypt \
        --with-openssl \
        --enable-mbstring \
        --enable-mbregex \
        --enable-ftp=shared \
        --with-kerberos \
        --enable-zip

And extension order:
extension=pdo.so
extension=sqlite.so
extension=sqlite3.so
extension=mysql.so
extension=mysqli.so
extension=pdo_mysql.so
extension=pdo_sqlite.so

Additionally if I load sqlite.so before pdo.so than I get 1 more error:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/sqlite.so: undefined symbol: php_pdo_unregister_driver in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/sqlite.so: undefined symbol: php_pdo_unregister_driver in Unknown on line 0
 [2010-02-23 03:54 UTC] l27n at yahoo dot com
Same problem, PHP 5.3.1, CENTOS 5.4
 [2010-04-05 15:41 UTC] koubel at volny dot cz
Year will be gone, and problem is still here: tested on 5.3.2 debian stable
 [2010-04-25 13:00 UTC] ovidio dot balan at gmail dot com
lol .. :(
 [2010-05-25 23:50 UTC] ashoat at gmail dot com
The problem is still occurring. There really ought to be a patch by now.
 [2010-06-08 12:52 UTC] kontakt at beberlei dot de
You can get this working with the following configure:

--without-sqlite --with-sqlite3=shared --with-pdo-sqlite=shared,/usr

More information in this thread: http://news.php.net/php.pdo/427
 [2010-10-14 19:21 UTC] jd at cpanel dot net
The problem is that pdo_sqlite compiles against the embedded copy of sqlite3 but doesn't include the sqlite3 object files in the final pdo_sqlite.so.

Ugly patch directly against the configure script:

--- php-5.3.3.orig/configure    2010-07-21 05:53:06.000000000 -0500
+++ php-5.3.3/configure 2010-10-14 09:40:17.000000000 -0500
@@ -75183,6 +75183,12 @@
 
   else
       # use bundled libs
+
+      # This change is anchored here to avoid patch being misapplied.  This really only needs to be added
+      # when pdo_sqlite is compiled shared and using the bundled sqlite3.  It shouldn't hurt so long as the
+      # bundled sqlite3 is used though.
+      shared_objects_pdo_sqlite="$shared_objects_pdo_sqlite ext/sqlite3/libsqlite/sqlite3.lo"
+
       if test "$enable_maintainer_zts" = "yes"; then
         threadsafe_flags="-DSQLITE_THREADSAFE=1"
       else
 [2012-06-13 02:43 UTC] kris dot glynn at virginaustralia dot com
I've just ran into this exact issue compiling php-5.3.13

I used..

--without-sqlite --with-sqlite3=shared --with-pdo-sqlite=shared

.. which still produced the "undefined symbol: sqlite3_libversion" error.

It wasn't until I tried the patch above to configure script from "jd at cpanel dot net" that the error goes away.

My question is why are we still having to do this with php-5.3.13 ? Am I missing something ?

My exact configure options are below..

./configure  --with-apxs2=/data/www2/apache/bin/apxs --prefix=/data/www2/apache --with-config-file-path=/data/www2/apache/php --with-openssl=/data/www2/apache --with-curl=/data/www2/apache --with-gd --enable-gd-native-ttf --with-png-dir=/data/www2/apache --with-jpeg-dir=/data/www2/apache --with-freetype-dir=/data/www2/apache --with-xpm-dir=/usr/X11R6/ --with-zlib-dir=/data/www2/apache --with-oci8=instantclient,/usr/lib/oracle/10.2.0.4/client/lib --with-libxml-dir=/data/www2/apache --with-mysql=/data/www2/apache --with-ldap=/data/www2/apache --with-pear=$BASE_PATH/pear/ --enable-pdo=shared --without-sqlite --with-sqlite3=shared --with-pdo-sqlite=shared --with-pdo-oci=shared,instantclient,/usr,10.2.0.4 --with-pdo-mysql=shared,/data/www2/apache --with-mcrypt=/data/www2/apache

(all the dependencies for php as you can see above exist in /data/www2/apache)
 [2012-06-27 10:29 UTC] rs at bytecamp dot net
This bug still exists in PHP-5.4.4.
When will it ever be fixed?
 [2013-08-12 16:40 UTC] michaeld at owl-online dot de
"Bug" still exists in php-5.4.17:

WÖRK-ARAUND (four us) ;-):

1. install sqlite3-devel
2. use this in you configure command (add /usr)
   --with-pdo-sqlite=shared,/usr

Cheers,
MD
 [2013-11-21 08:36 UTC] seyferseed at mail dot ru
I have this bug on PHP 5.5.3-1ubuntu2 (cli) (built: Oct  9 2013 14:49:12)

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/pdo_sqlite.so' - /usr/lib/php5/20121212/pdo_sqlite.so: undefined symbol: php_pdo_unregister_driver in Unknown on line 0
 [2014-01-01 12:50 UTC] felipe@php.net
-Package: PDO related +Package: PDO SQLite
 [2014-08-28 14:26 UTC] jaimz at vertigolabs dot org
I'm experiencing this with php 5.6
 [2014-08-28 14:28 UTC] jaimz at vertigolabs dot org
I retract my statement, I forgot to make clean before I recompiled it.
 [2015-06-19 08:32 UTC] rs at bytecamp dot net
This bug is still present in PHP-5.6.10 and can only be worked around by compiling against system's sqlite.
 [2015-08-26 14:23 UTC] jbhuguenin at assessfirst dot com
bug still present in PHP Version => 5.5.9-1ubuntu4.11
 [2015-12-22 13:27 UTC] mateusz at robopuff dot com
Bug preset in php => 7.0.0
 [2016-08-01 06:50 UTC] mybcbin at aliyun dot com
这个问题在php-5.6.24中仍然出现,出现的前提就是把pdo_sqlite作为动态的(so)编译的时候。
如果直接把它编译进php,就没有这样的问题。其实从它的文件夹中的config0.m4中的文件名可以看出,
官方是不建议编译成扩展库的。
 [2016-10-19 12:49 UTC] koubel at seznam dot cz
Yes, bug is still there - in PHP 7.0.12. Fix seems to be very easy, why isn't already applied? Using bundled sqlite as shared extension for both sqlite3 and pdo-sqlite is desired.
 [2017-10-24 06:12 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: scottmac +Assigned To:
 [2018-08-01 03:47 UTC] zrhoffman at ku dot edu
The problem still exists in PHP 7.2.8, and jd at cpanel dot net's patch still fixes it. Using Centos 6, here is my configuration:

Configure Command =>  './configure'  '--enable-intl' '--with-icu-dir=/home/myusername/opt/icu' '--with-config-file-path=/home/myusername/lib/php.ini' '--with-config-file-scan-dir=/home/myusername/lib' '--disable-opcache' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-mbstring' '--enable-pdo=shared' '--enable-soap' '--enable-sockets' '--enable-zip' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-curl=/opt/curlssl/' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-jpeg-dir=/usr' '--with-ldap' '--with-libdir=lib64' '--with-libxml-dir=/opt/xml2' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mssql' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/home/myusername/opt/pcre' '--with-pdo-mysql=shared' '--with-sqlite3=shared' '--with-pdo-sqlite=shared' '--with-pic' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--with-xsl=/opt/xslt/' '--with-zlib' '--with-zlib-dir=/usr'

This is built inside of a CentOS 6.10 docker container with only these packages installed (along with their dependencies):

openssh-clients gcc gcc-c++ libxml2-devel perl httpd httpd-devel php-devel openssl-devel freetype-devel libcurl-devel libjpeg-turbo-devel libpng-devel libXpm-devel mysql-devel libxslt-devel gd-devel sqlite-devel

Before applying the patch, I got this error at the end of `php --info`:

php: symbol lookup error: /home/myuser/lib/extension/pdo_sqlite.so: undefined symbol: sqlite3_libversion

After applying the patch, the error went away and everything worked normally.

In case it is useful to anyone, here is a quick sed command that fixes the configure:

sed -i 's/\(use bundled libs$\)/\1\nshared_objects_pdo_sqlite="\$shared_objects_pdo_sqlite ext\/sqlite3\/libsqlite\/sqlite3.lo"/' configure
 [2020-12-22 16:55 UTC] nikic@php.net
-Status: Open +Status: Wont fix
 [2020-12-22 16:55 UTC] nikic@php.net
sqlite has been unbundled in PHP 7.4, so this issue is no longer applicable (earlier PHP versions are not actively supported).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC