I'm trying to run a compiled 32-bit binary on a 64-bit CentOS 5.3 (based on RedHat 4.1.2) host. The binary complains about inability to find libmysqlclient.so.15. Such a file exists on the server, but it's 64-bit and therefore not good.

Can I install the 32-bit MySQL client libraries on the host? Preferably in the official way (i. e. via a repository). If not, what about a hackish way?

Also, is this a proper venue for such a question?

EDIT: here's an article that confirms that you cannot mix and match bitness within one process. But its recipe is not applicable to CentOS.

Wikipedia states that RHEL, which CentOS derives from, is capable of having a full 32-bit userland running along 64-bit... There are already some 32-bit libraries on the system - libc and such. Just not MySQL.

And why aren't you able to use the 64-bit client?
–
MDMarraMay 11 '12 at 17:01

Can you really use 64-bit libraries in 32-bit executables? Thought not. How are they going to agree on pointer size?
–
Seva AlekseyevMay 11 '12 at 17:07

HOW it is done is indeed implementation dependent and I am not from the RH world, but it is definitely possible. In the (unlikely) worst case some things will have to be manually installed, or the binary will need to run in a 32 bit chroot.
–
rackandbonemanMay 11 '12 at 17:34

2 Answers
2

1. Installation

Your MySQL installation could have come from different sources. It could be an rpm that came with the distribution or a Sun/Oracle rpm or it could have been built from sources.

rpm -q --whatprovides $(which mysql)

should tell you the name of the package like

MySQL-client-...

mysql-5.0...

mysql-community-server-client

mysql-5.1...

no package provides /usr/bin/mysql.

On CentOS the first two options are most likely. MySQL-client-5.0 is a Sun/Oracle RPM and mysql-5.0 could have come from the distribution. Use rpm -q --info <package_name> to get extended information and verify that the Vendor: line confirms the hypothesis.

1.1 MySQL from Sun/Oracle RPMs

If your mysql installation comes from Sun/Oracle, go to MySQL Community server download page, select among Generally Available (GA) releases the one that has mysql 5.0 version and 32-bit architecture, choose MySQL-shared-community package, download and install it with rpm -i. This package provides exactly the /usr/lib/libmysqlclient.so.15 library.

1.2 mysql from CentOS

In CentOS5 libmysqlclient belongs to the mysql package.

yum install mysql.i386

should do the trick.

In CentOS6 it was moved to a separate mysql-libs package.

2. Testing

After installing the library, check if dynamic library dependencies are resolved correctly:

ldd <your_binary> | grep libmysqlclient

should return something like

libmysqlclient.so.15 => /usr/lib/mysql/libmysqlclient.so.15

If you want to know what provides a 32-bit version of a specific 64-bit library, you could use rpm -q --whatprovides /path/to/your/lib64/library to determine the name of the package. Then replace x86_64 with i686 in the name to get the name of the 32-bit counterpart. Use yum search to verify if the package is provided by the repositories you have subscribed to.

@SevaAlekseyev My quess is that mysql was installed on the machine from Sun/Oracle rpms instead of the CentOS ones and CentOS rpms are on the exlcude list. You could check which version of x86_64 rpms is installed with rpm -q MySQL-client and get a corresponding i386 rpm from MySQL Community server dowlnoads
–
Dmitri ChubarovSep 29 '12 at 3:41