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

- Thread: https://externals.io/message/99728
- Original archive: https://news-web.php.net/php.internals/99728
- Started by Guillermo Cespedes on 2017-07-03T22:17:51+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #99728 — Guillermo Cespedes — 2017-07-03T22:17:51+00:00

URL: https://externals.io/message/99728#99728

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

:-/

---

## #99740 — johannes@php.net — 2017-07-04T16:10:39+00:00

URL: https://externals.io/message/99728#99740 · In reply to: #99728

Hi,


> 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.

---

## #99741 — Guillermo Cespedes — 2017-07-04T16:39:48+00:00

URL: https://externals.io/message/99728#99741 · In reply to: #99740

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,

> El 4 jul. 2017, a las 13:10, Johannes Schlüter <johannes@php.net> escribió:
> 
> Hi,
> 
> 
> > […]
> 
> [...]
> 
> > […]
> 
> 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.

---

## #99743 — johannes@php.net — 2017-07-04T17:09:25+00:00

URL: https://externals.io/message/99728#99743 · In reply to: #99741

> 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

---

## #99746 — Guillermo Cespedes — 2017-07-04T19:07:10+00:00

URL: https://externals.io/message/99728#99746 · In reply to: #99743

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.


> El 4 jul. 2017, a las 14:09, Johannes Schlüter <johannes@php.net> escribió:
> 
> 
> > […]
> 
> 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.
> 
> > […]
> 
> 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
