[MDEV-18818] mariadb_config reports wrong name for zlib on Fedora Created: 2019-03-05  Updated: 2021-06-29  Resolved: 2020-09-03

Status: Closed
Project: MariaDB Server
Component/s: Compiling, Scripts & Clients
Affects Version/s: 10.3.13
Fix Version/s: 10.2.35, 10.3.26, 10.4.16, 10.5.7

Type: Bug Priority: Major
Reporter: Daniël van Eeden Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

Fedora 29 on x86_64


Issue Links:
Duplicate
is duplicated by MDEV-21206 Can't link/include C library 'zlib', ... Closed

 Description   

Binary tarball: mariadb-10.2.21-linux-glibc_214-x86_64.tar.gz
Used with dbdeployer.

/path/to/mariadb_config --libs returns "-lzlib" which doesn't work on Fedora.
Using "-lz" does work.

This together with MDEV-15820 makes mariadb_config a pain if the compile time locations and runtime locations are not the same.



 Comments   
Comment by Daniël van Eeden [ 2019-03-05 ]

$ cat foo.c 
void main() {}
$ gcc foo.c -o foo
$ gcc foo.c -lzlib -o foo
/usr/bin/ld: cannot find -lzlib
collect2: error: ld returned 1 exit status
$ gcc foo.c -lz -o foo
$ ldd foo
	linux-vdso.so.1 (0x00007ffd823ee000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f99af1c4000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f99aeffe000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f99af210000)

Comment by Daniël van Eeden [ 2019-03-05 ]

$ ./bin/mariadb_config 
Copyright 2011-2015 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: ./bin/mariadb_config [OPTIONS]
  --cflags        [-I/usr/local/mysql/include/mysql -I/usr/local/mysql/include/mysql/mysql]
  --include       [-I/usr/local/mysql/include/mysql -I/usr/local/mysql/include/mysql/mysql]
  --libs          [-L/usr/local/mysql/lib/ -lmariadb -lzlib -ldl -lm -lpthread -l/usr/local/lib/libgnutls.a]
  --libs_r        [-L/usr/local/mysql/lib/ -lmariadb -lzlib -ldl -lm -lpthread -l/usr/local/lib/libgnutls.a]
  --libs_sys      [-lzlib -ldl -lm -lpthread -l/usr/local/lib/libgnutls.a]
  --version       [10.3.13]
  --cc_version    [3.0.9]
  --socket        [/tmp/mysql.sock]
  --port          [3306]
  --plugindir     [/usr/local/mysql/lib/plugin]
  --tlsinfo       [GnuTLS ]

Comment by Daniël van Eeden [ 2019-03-05 ]

Note that a recent version of Connector/C compiled on the same machine does work just fine:

$ /usr/local/bin/mariadb_config
Copyright 2011-2015 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: /usr/local/bin/mariadb_config [OPTIONS]
  --cflags        [-I/usr/local/include/mariadb -I/usr/local/include/mariadb/mysql]
  --include       [-I/usr/local/include/mariadb -I/usr/local/include/mariadb/mysql]
  --libs          [-L/usr/local/lib/mariadb/ -lmariadb -lz -ldl -lm -lpthread -lssl -lcrypto]
  --libs_r        [-L/usr/local/lib/mariadb/ -lmariadb -lz -ldl -lm -lpthread -lssl -lcrypto]
  --libs_sys      [-lz -ldl -lm -lpthread -lssl -lcrypto]
  --version       [10.3.6]
  --cc_version    [3.1.0]
  --socket        [/tmp/mysql.sock]
  --port          [3306]
  --plugindir     [/usr/local/lib/mariadb/plugin]
  --tlsinfo       [OpenSSL 1.1.1b]

Note the "-lz"

Comment by Georg Richter [ 2020-09-03 ]

After checking https://buildbot.askmonty.org/buildbot/builders/kvm-bintar-centos7-amd64-openssl/builds/1873/steps/compile/logs/stdio it seems that the build uses bundled zlib, sets ZLIB_FOUND and ZLIB_LIBRARY and then builds Connector/C with -DWITH_EXTERNAL_ZLIB=ON which doesn't make sense.

Comment by Georg Richter [ 2020-09-03 ]

Fixed in Connector/C

commit f3ed42f8775d9cba4d2e15551e83b3605a75cc49
Author: Georg Richter <georg@mariadb.com>
Date:   Thu Sep 3 17:34:55 2020 +0200
 
    Fix for MDEV-18818:
    
    When C/C is built within server, the server already sets ZLIB_FOUND
    and ZLIB_LIBRARY/INCLUDEDIR. In that case we need to link against the
    ZLIB_LIBRARY but we don't add it to the required system libraries.

Generated at Thu Feb 08 08:46:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.