Linux – Mint: correct way to install /lib/i386-linux-gnu/libgmp.so.3

librarieslinux-mint

I have a 32-bit binary that needs libgmp.so.3 on an x86_64 installation.

The cheating way would be copying libgmp.so.3 from an i386 installation and placing it in /lib/i386-linux-gnu/. But what is the proper way to install a 32-bit libgmp.so.3 on a 64-bit installation?

I tried aptitude install ia32-libs and while that does install a lot of 32-bit libs it does not install libgmp.so.3.

uname -a says:

Linux aspire 3.8.0-35-lowlatency #27-Ubuntu SMP PREEMPT Tue Dec 10 05:05:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

$ apt-file search libgmp.so
lib32gmp-dev: /usr/lib32/libgmp.so
lib32gmp10: /usr/lib32/libgmp.so.10
lib32gmp10: /usr/lib32/libgmp.so.10.0.5
libgmp-dev: /usr/lib/x86_64-linux-gnu/libgmp.so
libgmp10: /usr/lib/x86_64-linux-gnu/libgmp.so.10
libgmp10: /usr/lib/x86_64-linux-gnu/libgmp.so.10.0.5
libssl0.9.8: /usr/lib/x86_64-linux-gnu/ssl/engines/libgmp.so
libssl0.9.8-dbg: /usr/lib/debug/usr/lib/x86_64-linux-gnu/ssl/engines/libgmp.so
libssl1.0.0: /usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libgmp.so
libssl1.0.0-dbg: /usr/lib/debug/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libgmp.so

$ lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description:    Linux Mint 15 Olivia
Release:        15
Codename:       olivia

Best Answer

If you want to find out which package contains a particular file, you can use apt-file. If you want to search archives for a different architecture, you have to use the -a option, first to create/update the cache for that architecture (normal updating only creates/updates the default one) and then when searching. You can try:

sudo apt-file -a i386 update
apt-file -a i386 search /lib/i386-linux-gnu/libgmp.so.3

This should tell you the correct package to install. If the i386 isn't enabled for you system, you will have to enable it. You should be able to check with:

dpkg --print-foreign-architectures

If i386 isn't listed, you can add it with:

sudo dpkg --add-architecture i386

The above should work for newer Ubuntu versions, but for older ones you might have to do:

sudo dpkg --foreign-architecture i386

After adding, update the package lists:

sudo apt-get update

Then you should be able to install the package found from your apt-file search like this:

sudo apt-get install libwhatever:i386

If apt-file doesn't find anything, then it could mean that the library installs to a different place. You could try:

apt-file -a i386 search libgmp.so.3

Then install whatever package it finds. If you do this and you program still doesn't work, you could try symlinking /lib/i386-linux-gnu/libgmp.so.3 to wherever it does install to. Otherwise, if apt-file doesn't find anything, it likely means that there is no package which contains that version of the library in the repositories. You could then look for a package from a different version of Mint/Ubuntu (or the backports for your release may be a good place to start looking if the release's version is older). If you are really stuck, you would have to cross-compile and install from source.

Update

Your apt-file output, shows your distro libgmp package is libgmp10 which contains libgmp.so.10. Since you are looking for libgmp.so.3, there is no prizes for guessing this is an older version. No point looking in backports, since this is for newer packages.

A search on http://packages.ubuntu.com/ shows there is a libgmp3 in Ubuntu 12.04. The package page with links to the list of files is here - http://packages.ubuntu.com/precise/libgmp3c2. Installing the 32 bit package on 64 bit Ubuntu/Mint will put the files in different places though (ie libraries in /lib/i386-linux-gnu. You can download it here - http://packages.ubuntu.com/precise/i386/libgmp3c2/download

Usually this is can be problematic due to possible conflicts, but since the package has a different name it shouldn't conflict with any current libgmp. It also has only one dependency on libc6 which is the same as what is in Ubuntu 13.04 (the base for Olivia). There will be a different minor version, which may cause some odd bugs, but most likely you will be ok.

You can install like:

sudo dpkg -i dir/downloaded_package.deb

You may also have to install the i386 version of libc6 if you don't have it already:

sudo apt-get install libc6:i386
Related Question