7

So I'm running a program a college wrote on debian. When I do, the following error arises:

error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory 

I tried installing the following packages because of different search results I did:

apt-get install libmariadbclient-dev-compat
apt-get install default-libmysqlclient-dev
apt-get install mysql-common

Searches like:

find .  -name 'libmysqlclient*' 
locate libmysqlclient.so

Get's nothing as output.

I found a supposed fix using yum but as I am using debian it's not a solution for me. I found the .20 is something about Oracle MySQL 5.7 (https://community.centminmod.com/threads/libmysqlclient-so-missing.9052/)

Does anybody know how to fix the problem? Thanks in advance.

1
  • 1
    The cleaner solution is to recompile it on your system. Sep 27 '18 at 16:52
5

Apparently the program was compiled against a version of MySQL downloaded from www.mysql.com; libmysqlclient.so.20 was not available in Debian.

You can download a .deb from https://dev.mysql.com/downloads/file/?id=477124 that configures your Debian(-based) system to access the www.mysql.com apt repository. You can then update the apt data:

# apt-get update

and install the correct library:

# apt-get install libmysqlclient20

Note that this will probably want to remove your Debian version of MySQL, if installed! So consider carefully what you want.

An alternative is to browse the apt repository, and download just the libmysqlclient20 .deb manually. Unpack this, e.g.:

# dpkg-deb --extract libmysqlclient20_5.7.23-1debian9_amd64.deb /tmp/libmysqlclient20

You could then copy the libmysqlclient.so.20 to somewhere that's searched for shared libraries, e.g. /usr/local/lib/ and it should work.

1
  • Thanks! I tried the first method but strangely didn't work. However I did the second one and worked as charm. At first putting it in /usr/local/lib/ didn't worked so I put the file on /usr/lib/ and now is working. Thanks a lot! PS: sorry I don't upvote but I still have no reputation to do that. Oct 1 '18 at 10:22
4

In case someone else is running into this problem on Ubuntu 20.04, you can just add the older repos which will contain libmysqlclient20 to your APT sources (similar to Jylia Silver's answer.

sudo tee /etc/apt/sources.list.d/xenial.list > /dev/null <<EOF
deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe
deb http://dk.archive.ubuntu.com/ubuntu/ xenial-updates universe
EOF
sudo apt-get update
sudo apt-get install -y libmysqlclient20
2
echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list.d/unstable.list
apt-get update
apt-get install libmysqlclient20
1

Alternatively to the correct solution from wurtel, an unsafe, dirty, not suitable for production, hacky method is to simply create a symbolic link from a close enough version to the file the program is looking for:

  ln -s /usr/lib/libmysqulclient.so.23 /usr/local/lib/libmysqlclient.so.20

It may work or not. Most of the time, if the source file is only slightly newer, it should be fine. Of course I reiterate that this is unsafe and just for tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.