[MDEV-27109] mysql_config mariadb_config lists non existant -lmariadb Created: 2021-11-22  Updated: 2022-05-16  Resolved: 2022-01-14

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.5.11, 10.5.12, 10.5.13
Fix Version/s: 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6

Type: Bug Priority: Major
Reporter: tom brown Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None
Environment:

centos 7 and apparently centos 8 as well, based on your "official" yum repositories...

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=1


Issue Links:
Problem/Incident
causes MDEV-28581 MSI installer does not install client... Closed

 Description   

  --libs          [-L/usr/lib64/ -lmariadb]
  --libs_r        [-L/usr/lib64/ -lmariadb]

There is no mariadb library!!

The code I'm trying to build should be using -lmysqlclient but it's getting messed up flags from your build.

# rpm -qi MariaDB-devel
Name        : MariaDB-devel
Version     : 10.5.13
Release     : 1.el7.centos
Architecture: x86_64
Install Date: Mon 22 Nov 2021 11:24:01 AM PST
Group       : Applications/Databases
Size        : 57493407
License     : GPLv2
Signature   : DSA/SHA1, Sat 06 Nov 2021 02:36:23 PM PDT, Key ID cbcb082a1bb943db
Source RPM  : MariaDB-devel-10.5.13-1.el7.centos.src.rpm
Build Date  : Fri 05 Nov 2021 02:11:59 PM PDT
Build Host  : centos74-amd64
Relocations : (not relocatable)
Vendor      : MariaDB Foundation
URL         : http://mariadb.org

# mariadb_config 
Copyright 2011-2020 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: mariadb_config [OPTIONS]
Compiler: GNU 4.8.5
  --cflags        [-I/usr/include/mysql -I/usr/include/mysql/mysql]
  --include       [-I/usr/include/mysql -I/usr/include/mysql/mysql]
  --libs          [-L/usr/lib64/ -lmariadb]
  --libs_r        [-L/usr/lib64/ -lmariadb]
  --libs_sys      [-ldl -lm -lpthread -lssl -lcrypto]
  --version       [10.5.13]
  --cc_version    [3.1.15]
  --socket        [/var/lib/mysql/mysql.sock]
  --port          [3306]
  --plugindir     [/usr/lib64/mysql/plugin]
  --tlsinfo       [OpenSSL 1.0.2k]
  --variable=VAR  VAR is one of:
      pkgincludedir  [/usr/include/mysql]
      pkglibdir      [/usr/lib64]
      pkgplugindir   [/usr/lib64/mysql/plugin]

same thing on centos 8

[root@c8test ~]# rpm -qi MariaDB-devel
Name        : MariaDB-devel
Version     : 10.5.13
Release     : 1.el8
Architecture: x86_64
Install Date: Mon 22 Nov 2021 12:34:36 PM PST
Group       : Applications/Databases
Size        : 50887117
License     : GPLv2
Signature   : DSA/SHA1, Sat 06 Nov 2021 02:29:29 PM PDT, Key ID cbcb082a1bb943db
Source RPM  : MariaDB-devel-10.5.13-1.el8.src.rpm
Build Date  : Fri 05 Nov 2021 01:50:56 PM PDT
Build Host  : rhel8-amd64
Relocations : (not relocatable)
Vendor      : MariaDB Foundation
URL         : http://mariadb.org

and yes, if I use the command "correctly" I still get the wrong answers

[root@sup /home/virtuals/html]#  /usr/bin/mysql_config  --libs
-L/usr/lib64/ -lmariadb
[root@sup /home/virtuals/html]#  /usr/bin/mariadb_config  --libs
-L/usr/lib64/ -lmariadb
 
 
[root@sup /home/virtuals/html]# rpm -ql MariaDB-devel | grep \.a$
/usr/include/mysql/server/private/data
/usr/lib64/libmariadbclient.a
/usr/lib64/libmariadbd.a
/usr/lib64/libmysqlclient.a
/usr/lib64/libmysqlclient_r.a
/usr/lib64/libmysqld.a
/usr/lib64/libmysqlservices.a
[root@sup /home/virtuals/html]# rpm -ql MariaDB-devel | grep \.so$
/usr/lib64/libmysqlclient.so
/usr/lib64/libmysqlclient_r.so

there's a libmariadbd.a ... with a trailing d suffix, but no mariadb and definitely no libmariadb.so

I'm no developer. Maybe I'm doing something stupid. I'm just a sysadmin who has to maintain a pile of packages for a number of versions of centos. Mock is usually a good help for this, but it's going to make working around this bug quite ugly as you don't usually have root perms in a mock environment, and it's someone else's 60,000 line configure script that's getting tripped up.

Anyhow, submitting this in the hope it's legit and it saves someone else the 60 or 90 minutes it took me to figure out what the heck was going on.

p.s. 10.5.11 and 10.5.12 are still up on the repo, they show the same behaviour.



 Comments   
Comment by Sergei Golubchik [ 2021-11-23 ]

You're right. What we have now is

MariaDB-shared

/usr/lib64/libmariadb.so.3
/usr/lib64/libmariadb.so -> libmariadb.so.3

and

MariaDB-devel

/usr/lib64/libmariadbclient.a
/usr/lib64/libmysqlclient.so -> libmariadb.so.3
... more compatibility libmysqlclient* symlinks

This means that mariadb_config --libs can not be always correct, because the library name is different for dynamic and static builds. This is rather inconvenient.

Also libmariadb.so should be in -devel, not in -shared. And -devel has symlinks to files in -shared but does not require it.


But as far as you are concerned, as a sysadmin, I suspect it should mostly work fine for you. You likely prefer to link with libraries dynamically, not statically, so -lmariadb means you need libmariadb.so which is installed by MariaDB-shared.

Comment by Alexey Bychko (Inactive) [ 2021-11-26 ]

looking at 10.2.

if I understand everything correctly, we can fix it in following way:
1 - add dependency devel->shared
2 - move libmariadb.so to devel package

not sure about static/dynamic libraries. we have /usr/lib64/libmariadbclient.a and /usr/lib64/libmariadb.so symlink.
shall we create one more compatibility symlink (libmariadb.a -> libmariadbclient.a)?

the output from mariadb_config looks OK, I think we have nothing to change there

Comment by Sergei Golubchik [ 2021-11-26 ]

1. yes, 2. yes.

and yes, I thought about libmariadb.a -> libmariadbclient.a symlink too, we cannot just rename the library.

Don't forget to set CONFLICTS properly, this always needs to be done when a file to moved between packages

Comment by Alexey Bychko (Inactive) [ 2021-11-27 ]

created PR to add compatibility symlink https://github.com/mariadb-corporation/mariadb-connector-c/pull/190

Comment by Alexey Bychko (Inactive) [ 2021-11-27 ]

OK, so we have now a compatibility symlink, we have moved libmariadb.so to -devel.
but I'm not sure about CONFLICTS. is it to conflict with Oracle MySQL or we have another purpose?

Comment by Sergei Golubchik [ 2021-11-27 ]

No. They're always needed when a file is moved between packages. libmariadb.so was in MariaDB-shared-10.3..32, and will be in MariaDB-devel-10.3.33. Meaning one cannot install MariaDB-devel-10.3.33 and MariaDB-shared-10.3..32 at the same time, it'll be filesystem-level conflict error. To prevent it we have to tell rpm explicitly that these two packages conflict.

That is MariaDB-devel should have Require: MariaDB-shared >= 10.3.33
And MariaDB-shared should Conflict: Maria-devel < 10.3.33

(this was for 10.3, for 10.2, 10.4, 10.5, etc — adjust accordingly)

See cpack_rpm.cmake changes in 395a03323768, where my_print_defaults was moved from -server to -client.

Comment by Alexey Bychko (Inactive) [ 2021-11-28 ]

pushed to bb-10.2-MDEV-27109 as 69126ffc958543cb9a49984ec716103b943a8f53
I stuck a bit during submodule update, it shows detached HEAD probably due to lightweight checkout, not sure how to pin the revision I need properly.
maybe I need to wait until my PR will be merged to connector-c?

Comment by Sergei Golubchik [ 2022-01-05 ]

https://github.com/mariadb-corporation/mariadb-connector-c/pull/190

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