Diesel with MariaDB on CentOS 7

I'm having trouble working with Diesel on a CentOS 7 system with the latest version of MariaDB installed, and am interested in any pointers anyone might be able to give that could help me move forward.

I'm stuck at the very beginning of the process, unable to build the diesel command line tool that is needed to work with Diesel effectively.

In particular, when I try to build diesel-cli with the following command,

cargo install diesel_cli --no-default-features --features mysql

the build fails with the (infamous) error:

/usr/bin/ld: cannot find -lmysqlclient

I've tried a number of potential solutions to this error, but none have worked so far. (I can go into the potential solutions later in this thread; I don't want to bias things up front by discussing them now.)

So I'm wondering if anyone else has had any luck getting Diesel up and running on a CentOS 7 system with MariaDB, especially the latest stable version of Maria DB, and if so, what you had to do to get the setup to work.

Thanks!

EDIT: Here are the MariaDB packages I have installed on my system:

yum list installed mariadb*
Installed Packages
MariaDB-client.x86_64          10.3.13-1.el7.centos           @mariadb
MariaDB-common.x86_64          10.3.13-1.el7.centos           @mariadb
MariaDB-compat.x86_64          10.3.13-1.el7.centos           @mariadb
MariaDB-devel.x86_64           10.3.13-1.el7.centos           @mariadb
MariaDB-server.x86_64          10.3.13-1.el7.centos           @mariadb

Have you tried installing mysqlclient package? Maybe diesel could use mysql version of client to connect to MariaDB database. They, in theory, should be compatibile. You can check differences here.

I have not used MariaDB with Diesel. This just a first thought which came to my mind.

Thanks for the suggesting that I install mysqlclient.

However, the supposedly missing library is in fact installed on my system.

# find / -name *libmysqlclient* | egrep -v "gradle|tmp"
/usr/lib64/libmysqlclient.so.15
/usr/lib64/libmysqlclient.so.16.0.0
/usr/lib64/libmysqlclient.so.15.0.0
/usr/lib64/libmysqlclient_r.so.16.0.0
/usr/lib64/libmysqlclient.so.16
/usr/lib64/libmysqlclient.so.18
/usr/lib64/libmysqlclient.so.18.0.0
/usr/lib64/libmysqlclient_r.so.15
/usr/lib64/libmysqlclient_r.so.15.0.0
/usr/lib64/libmysqlclient_r.so.16

Also, if I try to install MySQL (which includes the mysql-client functionality), I get a not-so-surprising error:

# yum install mysql
Package MariaDB-client-10.3.13-1.el7.centos.x86_64 already installed and latest version
Nothing to do

I think the way to solve the problem will be to guide the build process for diesel-rs to find libmysqlclient on the system, but, despite multiple different tries, I haven't found a way to do that yet.

So I finally was able to build diesel-cli.

The issue that was keeping the build from finishing was that there were no libmysqlclient.so and libmysqlclient_r.so files in the directory where all the libmysqlclient files are located. Once I created these files as symbolic links to the most recent version of libmysqlclient.so, the build was able to finish with no errors.

I believe this problem is more likely to occur if, as is my case, you work with the most recent version of MariaDB from MariaDB, rather than the version that you get through the basic CentOS 7 repository. When I booted up a somewhat older version of CentOS 7 that uses the older version of MariaDB that comes with the distribution, I was able to build diesel-cli without any problems (after installing mariadb-devel). When I compared the libmysqlclient files between the two CentOS7 installations, I found that the new installation was missing the symbolic link files I mentioned earlier.

2 Likes

It'd be great if you could give that feedback to the mysqlclient-sys crate, so that it can improve its autodetection.

Which is a packaging error in the MariaDB-supplied RPMs. The -devel RPM should contain the .so symlinks, and it doesn't, as opposed to mariadb-devel from the base repo, which why building against those packages worked.

(I tried to leave a message along these lines on the Diesel Discourse, but it got trapped in the spam filter, sorry.)

1 Like

Did not know that. Thanks. I wish your post in the Diesel forum about this had gone through, but there seems to be a general issue with the spam protection in the forum. My original post in that forum thread was not approved until after almost 24 hours, and then only after I asked about activity in the forum in the Diesel Gitter.