/usr/bin/ld: cannot find -lmysqlclient | error: wrong mysql library version or lib not found

php.internals

Guillermo Cespedes

9 years ago
Hi, I am compiling MariaDB 10.2.6 and PHP 7.1.6 I'm trying it on Debian 8.8 32x / x64 on DigitalOcean See the script: https://gist.github.com/dertin/8de14e458dd4f0d3acb5f0deff120951 <https://gist.github.com/dertin/8de14e458dd4f0d3acb5f0deff120951> But I have problems compiling PHP with MariaDB # grep 'mysql’ config.log $ ./configure --prefix=/usr/local/php7 --enable-huge-code-pages --with-config-file-scan-dir=/usr/local/php7/etc/conf.d --without-pear --enable-bcmath --with-bz2 --enable-calendar --enable-intl --enable-exif --enable-dba --enable-ftp --with-gettext --with-gd --with-jpeg-dir --enable-mbstring --with-mcrypt --with-mhash --enable-mysqlnd --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-mysqli=/usr/local/mysql/bin/mariadb_config --with-pdo-mysql=/usr/local/mysql --with-openssl --enable-pcntl --with-pspell --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-zlib --enable-zip --with-readline --with-curl --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data .... configure:52615: result: /var/run/mysqld/mysqld.sock configure:52749: checking for mysql_set_server_option in -lmysqlclient configure:52774: cc -o conftest -I/usr/include -g -O2 -fvisibility=hidden -Wl,-rpath,/usr/local/mysql/lib/ -L/usr/local/mysql/lib/ -L/usr/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lmariadb -ldl -lm -lssl -lcrypto conftest.c -lmysqlclient -lmcrypt -lltdl -lstdc++ -lpng -lz -ljpeg -lcurl -lbz2 -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -ldl -lssl -lcrypto -lcurl -lxml2 -lz -lm -ldl -lssl -lcrypto -licui18n -licuuc -licudata -licuio >&5 /usr/bin/ld: cannot find -lmysqlclient | char mysql_set_server_option (); | return mysql_set_server_option (); configure:53081: error: wrong mysql library version or lib not found. Check config.log for more information. ac_cv_lib_mysqlclient___mysql_set_server_option=no :-/

Johannes Schlueter

9 years ago
Hi, On Mo, 2017-07-03 at 19:17 -0300, Guillermo Cespedes wrote:
> Hi, > > I am compiling MariaDB 10.2.6 and PHP 7.1.6 > > I'm trying it on Debian 8.8 32x / x64 on DigitalOcean > > See the script: > https://gist.github.com/dertin/8de14e458dd4f0d3acb5f0deff120951 > > But I have problems compiling PHP with MariaDB > > # grep 'mysql’ config.log
[...]
> configure:52749: checking for mysql_set_server_option in > -lmysqlclient
The cause for the behavior seems to be that the mysqli/config.m4 file checks your the information provided by the "config" program you passed, but for feature check uses the hard coded name of libmysql. Maybe this could be refactored to a simpler version check and discontinue support for versions before 5.0 ... if you send me the output from      mariadb_config --libs and     mariadb_config --version I can see if I can cook up a patch. That said: Preferred way is to build using mysqlnd instead of libmysql, so just use  --with-mysql and --with-pdo-mysql without path (or, in case you like it explicit, =mysqlnd for both) that's the client library optimized for PHP. See http://php.net/manual/en/mysqlinfo.library.choosing.php Also mind that MariaDB is a downstream fork of MySQL and both systems are diverting and likely will divert more over time. Experience can vary. johannes Note: I'm a member of Oracle's MySQL engineering team. Personal opinions. No promises from Oracle.

Guillermo Cespedes

9 years ago
Hi, Thanks for the reply # /usr/local/mysql/bin/mariadb_config # /usr/local/mysql/bin/mysql_config # my_print_defaults --mysqld See in: https://lists.launchpad.net/maria-discuss/msg04668.html <https://lists.launchpad.net/maria-discuss/msg04668.html> I also tried the following: --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-mysql-sock=/var/run/mysqld/mysqld.sock It returns an error that can not find mysql_config In an hour I'll try: --enable-mysqlnd=shared \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-mysql-sock=/var/run/mysqld/mysqld.sock As indicated here: https://lists.launchpad.net/maria-discuss/msg04674.html <https://lists.launchpad.net/maria-discuss/msg04674.html> Regards,

Johannes Schlueter

9 years ago
On Di, 2017-07-04 at 13:39 -0300, Guillermo Cespedes wrote:
> See in: https://lists.launchpad.net/maria-discuss/msg04668.html
Thanks, the --version output is of course unfortunate, as I can't distinguish in a good way between MariaDB and a future MySQL 10, except by guessing from program name ... anyways I'll see what I can do.
> I also tried the following: > > --enable-mysqlnd \ > --with-mysqli=mysqlnd \ > --with-pdo-mysql=mysqlnd \ > --with-mysql-sock=/var/run/mysqld/mysqld.sock > > It returns an error that can not find mysql_config
Works nicely for my:system, which doesn't have mysql_config in PATH: $ mysql_config The program 'mysql_config' is currently not installed. You can install it by typing: sudo apt install libmysqlclient-dev $ sapi/cli/php -v PHP 7.1.8-dev (cli) (built: Jul  4 2017 19:05:05) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies $ sapi/cli/php -i | grep Configure Configure Command =>  '../../php-7.1/configure'  '--enable-mysqlnd' ' --with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-mysql- sock=/var/run/mysqld/mysqld.sock' Maybe you have old autoconf cache files lying around or such? Can you try on a clean tree? If this doesn't help please provide the config.log file. johannes

Guillermo Cespedes

9 years ago
Hi, Johannes - I have cleaned the build directory. - "source /etc/profile" globally - set the values with "shared, mysqlnd” With the last 3 changes, I have managed to compile PHP. See diff: https://gist.github.com/dertin/8de14e458dd4f0d3acb5f0deff120951/revisions?diff=split <https://gist.github.com/dertin/8de14e458dd4f0d3acb5f0deff120951/revisions?diff=split> I'll try without the shared library. I do not understand much that it is better, to use or not to use shared libraries mysqlnd VS shared,mysqlnd I will continue to fix and improve the script. # /usr/local/php7/bin/php -v PHP 7.1.6 (cli) (built: Jul 4 2017 18:43:51) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies # /usr/local/php7/bin/php -i | grep Configure Configure Command => './configure' '--prefix=/usr/local/php7' '--enable-huge-code-pages' '--with-config-file-scan-dir=/usr/local/php7/etc/conf.d' '--without-pear' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-intl' '--enable-exif' '--enable-dba' '--enable-ftp' '--with-gettext' '--with-gd' '--with-jpeg-dir' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--enable-mysqlnd=shared' '--with-mysqli=shared,mysqlnd' '--with-pdo-mysql=shared,mysqlnd' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-openssl' '--enable-pcntl' '--with-pspell' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--with-zlib' '--enable-zip' '--with-readline' '--with-curl' '--enable-simplexml' '--enable-xmlreader' '--enable-xmlwriter' '--enable-fpm' '--with-fpm-user=www-data' '--with-fpm-group=www-data’ Thanks for the help.