[MDEV-21206] Can't link/include C library 'zlib', aborting. during MariaDb installation Created: 2019-12-03  Updated: 2021-07-12  Resolved: 2021-07-12

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.2.29
Fix Version/s: 10.2.40, 10.3.31, 10.4.21, 10.5.12, 10.6.4

Type: Bug Priority: Critical
Reporter: Ragul Assignee: Robert Bindar
Resolution: Fixed Votes: 0
Labels: MariaDB-server, installation

Issue Links:
Duplicate
duplicates MDEV-18818 mariadb_config reports wrong name for... Closed
is duplicated by MDEV-24158 Mysql_config has lzlib reference inst... Closed

 Description   

While installing MariaDB its unable to link Zlib library and ended with below error.

I will use the following settings for compiling and testing:
 
  cflags        (mysql_config) = -I/opt/alu-rp/mysql/include/mysql -I/opt/alu-rp/mysql/include/mysql/..
  embedded      (mysql_config) = 
  ldflags       (guessed     ) = 
  libs          (mysql_config) = -L/opt/alu-rp/mysql/lib -lmariadb -lpthread *-lzlib* -ldl -lm -lgnutls
  mysql_config  (guessed     ) = mysql_config
  nocatchstderr (default     ) = 0
  nofoundrows   (default     ) = 0
  nossl         (default     ) = 0
  testdb        (default     ) = test
  testhost      (default     ) = 
  testpassword  (default     ) = 
  testport      (default     ) = 
  testsocket    (default     ) = 
  testuser      (guessed     ) = 
 
To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.
 
Checking if libs are available for compiling...
Can't link/include C library 'zlib', aborting.

But I could see the zlib need to be accessed as -lz

[root@motiveche076 ~]# pkg-config zlib --libs
-lz



 Comments   
Comment by Daniel Black [ 2020-10-02 ]

This has been fixed:

mariadb-10.2.34

Usage: scripts/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/local/mysql/include/mysql -I/usr/local/mysql/include/mysql/.. ]
        --include        [-I/usr/local/mysql/include/mysql -I/usr/local/mysql/include/mysql/..]
        --libs           [-L/usr/local/mysql/lib  -lmariadb -lpthread -lz -ldl -lm -lssl -lcrypto]
        --libs_r         [-L/usr/local/mysql/lib  -lmariadb -lpthread -lz -ldl -lm -lssl -lcrypto]
        --plugindir      [/usr/local/mysql/lib/plugin]
        --socket         [/tmp/mysql.sock]
        --port           [0]
        --version        [10.2.34]
        --libmysqld-libs [-L/usr/local/mysql/lib  -lmysqld]
        --variable=VAR   VAR is one of:
                pkgincludedir [/usr/local/mysql/include/mysql]
                pkglibdir     [/usr/local/mysql/lib]
                plugindir     [/usr/local/mysql/lib/plugin]

Comment by Ragul [ 2020-11-06 ]

Able to see the lz in mysql_config but not in the mariadb-10.2.35-linux-x86_64.tar.gz

https://downloads.mariadb.org/interstitial/mariadb-10.2.35/bintar-linux-x86_64/mariadb-10.2.35-linux-x86_64.tar.gz

[root@t bin]# grep zlib mysql_config
libs="-L$pkglibdir -lmariadb -lpthread -lzlib -ldl -lm -lgnutls"

Comment by Ragul [ 2021-01-05 ]

Hi Daniel, Do we have any update on this ticket?
And Is this planned for any release?

Comment by Daniel Black [ 2021-01-07 ]

I'm on leave until next week. As a critical bug it will be fixed before next release (end of month approximately)

Comment by Karthikeyan [ 2021-02-23 ]

Could someone provide any update on this?

Comment by Daniel Black [ 2021-04-13 ]

Haven't looked yet however its on critical priority for the next release at the end of the month.

Comment by Sergei Golubchik [ 2021-05-03 ]

This is not a Connector/C issue, mysql_config is a script from the server tree, in scripts/

Comment by Sergei Golubchik [ 2021-05-03 ]

not fixed in the latest (as of now) mariadb-10.2.38-linux-x86_64.tar.gz from buildbot

Comment by Robert Bindar [ 2021-07-01 ]

Hi RagulR! I'm trying to investigate this and I can't figure out whether mysql_config was wrong to suggest you `-lzlib` and it should've instead suggested `-lz`, or it shouldn't suggest `-lzlib` at all. Is it possible to remove the `-lzlib` flag by hand in whatever you are compiling and see if the error goes away?

Comment by Ragul [ 2021-07-01 ]

Thanks for the investigation, Robert.
Yes, I currently overriding the flag '-lzlib' as '-lz' to unblock my installation.

But I could see the zlib need to be accessed as -lz instead of '-lzlib'

 
[root@~]# pkg-config zlib --libs
-lz

Comment by Robert Bindar [ 2021-07-01 ]

Good that you unblocked your installation! So ideally mysql_config/mariadb_config should output `-lzlib` only when running the script from within a build-from-sources mariadb server (and that server is built with -DWITH_ZLIB=bundled) and in that case it is correct, because the bundled version of zlib results in a static library called 'libzlib.a'.
But for binary tarballs it should never happen, mysql_config should call mariadb_config behind the scenes and that should only return '-lmariadb' (in theory) as linking flag starting with 10.2 (for sure it should never return '-lzlib' because we don't even ship any libzlib.a in our tarballs).

I would appreciate a lot if you could help me understand why mysql_config behaves that way for you.
I need to know some internal values from within the script, you can obtain them by going into the script and add something like this before the script exits:
> echo "########"
> echo $basedir
> ls -l $basedir/bin/
> echo $me

Let me know if you need help with that.

Comment by Robert Bindar [ 2021-07-02 ]

Also RagulR, I would appreciate a lot if you could try your installation without any '-lz' or '-lzlib' at all.

Comment by Robert Bindar [ 2021-07-12 ]

Fixed with b082716892071fdc3c961e9afaa011e0f6beb102

Generated at Thu Feb 08 09:05:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.