php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #35432 make fails with PDO and MySQL5
Submitted: 2005-11-27 22:31 UTC Modified: 2006-09-06 10:25 UTC
Votes:4
Avg. Score:2.8 ± 1.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: mail at philipp-wagner dot com Assigned: dbs (profile)
Status: Closed Package: Documentation problem
PHP Version: 5CVS-2005-11-27 (snap) OS: SuSE Linux 8.0
Private report: No CVE-ID: None
 [2005-11-27 22:31 UTC] mail at philipp-wagner dot com
Description:
------------
I get the same error as in bug #34939 with PHP 5.1.0 (official release) and also today's snapshot release. During the final linking process of make, I get the following error:

ext/pdo_mysql/.libs/pdo_mysql.o: In function `zm_startup_pdo_mysql':
/usr/local/src/php5-200511271530/ext/pdo_mysql/pdo_mysql.c:78: undefined referen
ce to `php_pdo_declare_long_constant'
/usr/local/src/php5-200511271530/ext/pdo_mysql/pdo_mysql.c:79: undefined referen
ce to `php_pdo_declare_long_constant'
/usr/local/src/php5-200511271530/ext/pdo_mysql/pdo_mysql.c:80: undefined referen
ce to `php_pdo_declare_long_constant'
/usr/local/src/php5-200511271530/ext/pdo_mysql/pdo_mysql.c:81: undefined referen
ce to `php_pdo_declare_long_constant'
/usr/local/src/php5-200511271530/ext/pdo_mysql/pdo_mysql.c:82: undefined referen
ce to `php_pdo_declare_long_constant'
/usr/local/src/php5-200511271530/ext/pdo_mysql/pdo_mysql.c:84: undefined referen
ce to `php_pdo_register_driver'
ext/pdo_mysql/.libs/pdo_mysql.o: In function `zm_shutdown_pdo_mysql':
/usr/local/src/php5-200511271530/ext/pdo_mysql/pdo_mysql.c:92: undefined referen
ce to `php_pdo_unregister_driver'
ext/pdo_mysql/.libs/mysql_driver.o: In function `_pdo_mysql_error':
/usr/local/src/php5-200511271530/ext/pdo_mysql/mysql_driver.c:109: undefined ref
erence to `php_pdo_get_exception'
ext/pdo_mysql/.libs/mysql_driver.o: In function `mysql_handle_preparer':
/usr/local/src/php5-200511271530/ext/pdo_mysql/mysql_driver.c:178: undefined ref
erence to `pdo_parse_params'
ext/pdo_mysql/.libs/mysql_driver.o: In function `pdo_mysql_last_insert_id':
/usr/local/src/php5-200511271530/ext/pdo_mysql/mysql_driver.c:259: undefined ref
erence to `php_pdo_int64_to_str'
ext/pdo_mysql/.libs/mysql_driver.o: In function `pdo_mysql_handle_factory':
/usr/local/src/php5-200511271530/ext/pdo_mysql/mysql_driver.c:412: undefined ref
erence to `php_pdo_parse_data_source'
ext/pdo_mysql/.libs/mysql_statement.o: In function `pdo_mysql_stmt_param_hook':
/usr/local/src/php5-200511271530/ext/pdo_mysql/mysql_statement.c:338: undefined
reference to `pdo_raise_impl_error'
ext/pdo_sqlite/.libs/pdo_sqlite.o: In function `zm_startup_pdo_sqlite':
/usr/local/src/php5-200511271530/ext/pdo_sqlite/pdo_sqlite.c:80: undefined refer
ence to `php_pdo_register_driver'
ext/pdo_sqlite/.libs/pdo_sqlite.o: In function `zm_shutdown_pdo_sqlite':
/usr/local/src/php5-200511271530/ext/pdo_sqlite/pdo_sqlite.c:87: undefined refer
ence to `php_pdo_unregister_driver'
ext/pdo_sqlite/.libs/sqlite_driver.o: In function `_pdo_sqlite_error':
/usr/local/src/php5-200511271530/ext/pdo_sqlite/sqlite_driver.c:78: undefined re
ference to `php_pdo_get_exception'
ext/pdo_sqlite/.libs/sqlite_driver.o: In function `pdo_sqlite_last_insert_id':
/usr/local/src/php5-200511271530/ext/pdo_sqlite/sqlite_driver.c:197: undefined r
eference to `php_pdo_int64_to_str'
ext/pdo_sqlite/.libs/sqlite_driver.o: In function `zif_SQLite_sqliteCreateFuncti
on':
/usr/local/src/php5-200511271530/ext/pdo_sqlite/sqlite_driver.c:471: undefined r
eference to `pdo_raise_impl_error'
ext/pdo_sqlite/.libs/sqlite_driver.o: In function `zif_SQLite_sqliteCreateAggreg
ate':
/usr/local/src/php5-200511271530/ext/pdo_sqlite/sqlite_driver.c:543: undefined r
eference to `pdo_raise_impl_error'
ext/pdo_sqlite/.libs/sqlite_driver.o: In function `pdo_sqlite_handle_factory':
/usr/local/src/php5-200511271530/ext/pdo_sqlite/sqlite_driver.c:697: undefined r
eference to `php_pdo_get_exception'
ext/pdo_sqlite/.libs/sqlite_statement.o: In function `pdo_sqlite_stmt_param_hook
':
/usr/local/src/php5-200511271530/ext/pdo_sqlite/sqlite_statement.c:116: undefine
d reference to `pdo_raise_impl_error'
ext/sqlite/.libs/sqlite.o: In function `zm_startup_sqlite':
/usr/local/src/php5-200511271530/ext/sqlite/sqlite.c:1100: undefined reference t
o `php_pdo_register_driver'
ext/sqlite/.libs/sqlite.o: In function `zm_shutdown_sqlite':
/usr/local/src/php5-200511271530/ext/sqlite/sqlite.c:1113: undefined reference to `php_pdo_unregister_driver'
ext/sqlite/.libs/pdo_sqlite2.o: In function `_pdo_sqlite2_error':
/usr/local/src/php5-200511271530/ext/sqlite/pdo_sqlite2.c:291: undefined reference to `php_pdo_get_exception'
ext/sqlite/.libs/pdo_sqlite2.o: In function `pdo_sqlite2_last_insert_id':
/usr/local/src/php5-200511271530/ext/sqlite/pdo_sqlite2.c:373: undefined reference to `php_pdo_int64_to_str'
ext/sqlite/.libs/pdo_sqlite2.o: In function `pdo_sqlite2_handle_factory':
/usr/local/src/php5-200511271530/ext/sqlite/pdo_sqlite2.c:579: undefined reference to `php_pdo_get_exception'


Reproduce code:
---------------
I am using MySQL 5.0.16 and my configure line was as follows:

'./configure' '--enable-trans-sid' '--enable-memory-limit' '--with-config-file-path=/etc' '--enable-xslt' '--with-xslt-sablot' '--enable-ftp' '--enable-bcmath' '--with-bz2' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql=/usr/local/mysql' '--with-gzip' '--with-bzip2' '--with-gd' '--with-jpeg-dir=/usr/lib' '--with-zlib-dir=/usr/lib' '--with-iconv-dir=/usr/local/lib' '--with-iconv=/usr/local/lib' '--with-freetype-dir' '--enable-gd-native-ttf' '--with-magickwand=/usr/local' --enable-pdo=shared --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring

I didn't get any error when I was compiling PHP without any PDO configure option, it built fine with PDO support for sqlite. Unfortunately it's hard for me to try every possible combination of configure lines which may cause the problem, as a make process takes about two hours on my machine. But if you need me to try a certain configure line, I'll be glad to provide you with the results.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-27 22:40 UTC] tony2001@php.net
Wez, one more for you.
 [2005-11-27 23:43 UTC] sniper@php.net
One note about your usage of the configure options: There aren't any options that expect the path to the libraries.
Every single one of them expects the install prefix.
In most cases it's either /usr or /usr/local and not /usr/lib or /usr/local/lib..

 [2005-11-28 17:53 UTC] mail at philipp-wagner dot com
Yes, I see that now too, but it's not a problem for MySQL, as /usr/local/mysql is the prefix (it's a MySQL binary .tar.gz distribution).
 [2005-11-30 05:48 UTC] wez@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip

Please try the next PHP 5.1 snapshot.
It features an improved error message that should catch conflicting configure options.
 [2005-11-30 16:25 UTC] mail at philipp-wagner dot com
Well, I thought this might be the problem (mixing of shared and static libraries)... But now the check seems to be too strict.

I first tried to build with  --enable-pdo=shared --with-pdo-mysql=shared,/usr/local/mysql

Now I got the following error message:
You've configured extension sqlite to build statically, but it depends on extension pdo, which you've configured to build shared.
You either need to build sqlite shared or build pdo statically for the build to be successful.

sqlite is enabled by default (I didn't specify exlicitly specify pdo sqlite support as a configure option).

./configure --help doesn't say anything about an option like --with-pdo-sqlite, but I tried to use it anyways (or what else should I do to specify shared pdo sqlite support?). So I ran ./configure with --with-pdo-sqlite=shared

This worked out quite well at first, configure gave me an output like

checking for sqlite 3 driver for PDO... yes, shared

But then, a bit further down, I got the error message again:

checking for PDO includes... (cached) /usr/local/src/php5.1-200511301330/ext
checking for lemon... no
configure: warning: lemon versions supported for regeneration of libsqlite parsers: 1.0 (found: none).
configure: error:
You've configured extension sqlite to build statically, but it depends on extension pdo, which you've configured to build shared.
You either need to build sqlite shared or build pdo statically for the build to be successful.

I actually think, if you specify --enable-pdo=shared, all pdo "submodules" should also be built shared, as it reduces confusion and is the only way to get a working build anyways  (it seems it is not possible to mix shared and static pdo libraries, so there's no need to specify it seperately).

Also, the documentation doesn't say anything about how to build the specific PDO modules. It just suggests building PDO with --enable-pdo=shared, but doesn't say which configure options to use for MySQL PDO support etc. (I just got it from the ./configure --help output), and also doesn't mention the shared "problem".
 [2005-11-30 17:31 UTC] sniper@php.net
Wez, so, enabling by default is good thing? 
Hint: You should always use --disable-all :)
 [2005-11-30 18:47 UTC] wez@php.net
You "simply" need to tell configure to build what you want it to build, how you want it built.

--enable-pdo=shared
--with-pdo-mysql=shared,/usr/local/mysql
--with-sqlite=shared

I know it sucks that we can't automatically make it work that way you want it; configure scripts have their limitations.

 [2005-11-30 20:15 UTC] mail at philipp-wagner dot com
It's really a documentation problem then. It's NOT enough to just specify (as you wrote above)
--enable-pdo=shared
--with-pdo-mysql=shared,/usr/local/mysql
--with-sqlite=shared

I had to use
--enable-pdo=shared
--with-pdo-mysql=shared,/usr/local/mysql
--with-sqlite=shared
--with-pdo-sqlite=shared

to get it to work. This really should be be mentioned in the documentation. The documentation only suggests to compile with --enable-pdo=shared, but that won't work, if you don't use at least the corresponding sqlite configure options also.
 [2005-11-30 21:42 UTC] mail at philipp-wagner dot com
I'm really sorry that I'm adding again some small thing, but I figured out that it is also important in which order you load the modules. You have to load the PDO modules first, before you load the sqlite module, otherwise you get the following error:
<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20050922/sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20050922/sqlite.so: undefined symbol: php_pdo_register_driver in <b>Unknown</b> on line <b>0</b><br />

The PDO modules are loaded correctly, but the sqlite module won't until you place the extension=sqlite.so line in the php.ini file after the pdo extensions. 

That should be mentioned in the documentation also.
 [2005-11-30 21:47 UTC] nlopess@php.net
Dan, can you take a look at this please?
 [2005-12-01 04:59 UTC] dbs@php.net
Wow... this is a bit of a complex beast. So to summarize, the documentation updates we're looking at:

1. If PDO is built as a shared modules, all PDO drivers must also be built as shared modules.
2. If ext/pdo_sqlite is built as a shared module, ext/sqlite must also be built as a shared module.
3. In the extensions entries, if ext/pdo_sqlite is built as a shared module, php.ini must specify pdo_sqlite first, followed by sqlite.
 [2005-12-01 18:08 UTC] mail at philipp-wagner dot com
That's it.
 [2005-12-10 05:00 UTC] wez@php.net
Points 2 and 3 from Dans comment are not true; sorry Dan :)

ext/pdo_sqlite is totally independent from ext/sqlite.
The shared/static-ness of them has nothing to do with each other.
The key thing is that if PDO is shared, then all extensions that implement PDO drivers must also be built shared.
ext/sqlite implements the sqlite2 PDO driver, so it must be built shared if PDO is shared.
Ordering in php.ini; pdo.so must be first; the order of the other PDO drivers should not matter.

 [2006-01-13 15:54 UTC] luke dot crouch at gmail dot com
I'm not sure if this is still being called a "bug" but I experienced it while compiling php 5.1.1 on RHEL3 ES.

To get a correct make after using --enable-pdo=shared, I had to explicitly add these options as well:

--with-pdo-informix=shared --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-sqlite=shared

I know the informix and/or MySQL share instructions might be unnecessary, but I got it to work this way, so I'm sticking with it! ;) I think the combination of 
--with-sqlite=shared --with-pdo-sqlite=shared
is the important part.
 [2006-01-14 17:23 UTC] mail at philipp-wagner dot com
It's a documentation problem, as it seems that there's no way to let the configure script correct the options for you. Unfortunately, the documentation hasn't been updated up to now, so you won't find any advice until you search the bug database.
 [2006-01-16 02:03 UTC] dbs@php.net
I have added a note to the PDO installation section for Unix, stating that if PDO is built as a shared extension, all PDO drivers must be built as shared extensions.
 [2006-01-30 20:01 UTC] mail at philipp-wagner dot com
I am really sorry to have to reopen that bug, but it's still not really clear from the documentation what the problem exactly is. You suggest building PDO as
./configure --with-zlib --enable-pdo=shared
That's not enough! You have to build at least also sqlite as shared lib, with only these arguments, make will fail!
 [2006-01-30 20:17 UTC] dbs@php.net
I'm sorry, but we cannot document every possible combination of configure options.

If you do use "./configure --with-zlib --enable-pdo=shared", the configure script in PHP 5.1.2 returns the following message:

configure: error:
You've configured extension pdo_sqlite to build statically,
but it depends on extension pdo, which you've configured to
build shared. You either need to build pdo_sqlite shared or
build pdo statically for the build to be successful.

Between the statement in the documentation that "if you build PDO as a shared extension, you must build the PDO drivers as shared extensions" and the extremely helpful configure error messages, users will be able to figure this out.

 [2006-01-30 20:27 UTC] mail at philipp-wagner dot com
But where's the point of having an example configure line in the docs (and the one I quoted is exactly from the docs) which does not work the way it is written there? Sure, the user will know what he has to change after he tried it, but why document it wrong in the first place?
 [2006-09-06 10:25 UTC] nlopess@php.net
already fixed in the manual.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 14:01:31 2024 UTC