3

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
7
  • You need to install the 32 bit package for the library, probably by giving its name with .i686 or something similar. I'm not familiar with Mint, sorry.
    – vonbrand
    Mar 15, 2014 at 17:38
  • possible duplicate of How do I run 32-bit programs on a 64-bit Debian/Ubuntu?
    – terdon
    Mar 16, 2014 at 5:17
  • @vonbrand is correct - use the package manager. Don't randomly copy library files you think might help unless you've tried everything else and know exactly what you're doing.
    – Shadur
    Mar 16, 2014 at 10:08
  • 1
    @terdon Unfortunately, while Debian and Ubuntu have multiarch support, Mint as of right now doesn't yet, so that answer doesn't help unless you want to add "Remove mint and install debian or ubuntu"
    – Shadur
    Mar 16, 2014 at 10:09
  • @Shadur In my case it would not be random guessing: It would be based on the output from ldd. But without knowing the correct package to install, I do not see how your comment is useful. Can you elaborate?
    – Ole Tange
    Mar 16, 2014 at 10:53

1 Answer 1

2

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
6
  • Good guide, but the last part is quite sketchy: apt-file -a i386 search libgmp.so.3 returns nothing, so how do you find repositories containing the file?
    – Ole Tange
    Mar 16, 2014 at 19:00
  • @Ole, I figured you probably wouldn't need it, so I was just laying down rough ideas. I will update, but please post the version of Mint you are using (lsb_release -a) and what version of libgmp.so it does have (apt-file search libgmp.so).
    – Graeme
    Mar 16, 2014 at 19:12
  • @Ole, updated my answer
    – Graeme
    Mar 17, 2014 at 0:31
  • one slight improvement before I accept your answer: How do you know libgmp3c2 contains the right file (apart from the pretty relevant package name)? How did you find the download URL of that package? I imagine you used some sort of online apt-file search that covers many repositories to locate the package, but it would be great if you include which.
    – Ole Tange
    Mar 17, 2014 at 8:35
  • And BTW the above worked.
    – Ole Tange
    Mar 17, 2014 at 10:25

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.