171

I installed Ubuntu 14.04 and the current Android development SDK, which contains 32-bit executables. I found that I cannot run those 32-bit binaries. Trying to start them from bash gives me an error:

$ ./adb
bash: ./adb: No such file or directory

It is there though:

$ ls -al ./adb
-rwxrwxrwx 1 thomas thomas 1231255 Jan 17 13:31 ./adb
$ file ./adb
./adb: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped. 

Same symptom for all the other 32-bit tools in the Android SDK.

In olden days one could just install 32-bit libraries on 64-bit Ubuntu to get 32-bit support, but that does not seem to work anymore.

How do I run 32-bit apps on a 64-bit Ubuntu distribution?

mathway
  • 1,694

5 Answers5

251

To run a 32-bit executable file on a 64-bit multi-architecture Ubuntu system, you have to add the i386 architecture and install the three library packages libc6:i386, libncurses5:i386, and libstdc++6:i386:

sudo dpkg --add-architecture i386

Or if you are using Ubuntu 12.04 LTS (Precise Pangolin) or below, use this:

echo "foreign-architecture i386" > /etc/dpkg/dpkg.cfg.d/multiarch

Then:

sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

If fails, do also

sudo apt-get install multiarch-support

After these steps, you should be able to run the 32-bit application:

./example32bitprogram
Pablo Bianchi
  • 15,657
Avinash Raj
  • 78,556
  • @AvinashRaj This helped me out! However, what is the last command "sudo ./adb" supposed to do actually? – Marcel May 22 '14 at 21:33
  • 1
    It executes the 32bit adb binary file which was present in the current directory. – Avinash Raj May 23 '14 at 01:05
  • 1
    to get aapt working on Ubuntu 14.04, I had to install lib32z1 as well, but noticed it pulled in libc6-i386 (distinction, notice the hyphen, not the colon). – Chris Betti May 23 '14 at 19:09
  • 1
    I did your steps, libc6:i386, libncurses5:i386, libstdc++6:i386 are newest version and set to manually installed. But after that it says: "Soma packages could not be installed.This may mean you have requested impossible situation or you are using unstable distribution ..." and unmet dependancies: libstdc++6-4.4-dev:i386 depends g++-4.4:i386(wont be installed). conflicts: libstdc++6-4.4-dbg:i386 ... and other conflicts about libstdc++6-4.4/6/7 etc. What is wrong or should i leave it as it is now? – Fredrick Gauss Jun 04 '14 at 06:09
  • @FredrickGauss get into here. – Avinash Raj Jun 04 '14 at 06:13
  • I couldn't get into there but for now it seems working, thanks. – Fredrick Gauss Jun 25 '14 at 12:08
  • I know it is an Ubuntu Q&A, but in case anyone heads here (as did I), that procedure worked on Debian Stretch 9.0 x64 too – Antônio Medeiros Jul 11 '17 at 14:35
  • Totally stuck exactly like @FredrickGauss after a fresh Ubuntu 14.04.6 install. libstdc++6:i386 is blocked with dependency after blocking dependency after blocking dependency etc. Switching to a 32-bit install. – juanitogan Aug 29 '20 at 21:33
  • @FredrickGauss only libstdc++6:i386 has conflicts, I install the other package, it works – netawater Sep 24 '21 at 01:49
  • is it normal that after i sudo apt-add-architecture i386 and i sudo apt update, my ubuntu 18.06 boots into a tty? – franzeph Jul 12 '22 at 03:13
12

"No such file or directory" may appaear when you have your binary, but it lacks some libraries. If you install build-essential package, you will have ldd command available. This command ldd ./adb | grep not will show you what libraries are missing. Just install these libraries in i386 arch with apt. Like this: apt-get install libmissing:i386 Beware, some buggy packages will try to delete 64bit version firs.

  • Thank you, that would explain the weird error message.

    I was first confused why bash would give me this error (instead of some error coming more clearly from the child process which misses the libraries), but now I guess bash just sees exec(3) returning ENOENT and prints this out.

    – Thomas Stuefe Apr 24 '14 at 12:30
9

Additionally to the excellent answer of Zanna and Avinash Raj I had to install gcc-multilib as well:

sudo apt-get install gcc-multilib

Possibly this is because I wanted to run an old gcc version on 64bit.

5

And if you want to use "adb" there is a package for it:

sudo apt-get install android-tools-adb

And about 32-bit libraries - only:

sudo apt-add-architecture i386

will be enough.

Anwar
  • 76,649
aastefanov
  • 1,391
  • 12
  • 16
  • Thanks for the tip, but I wanted to use the android tools downloaded from google, not the ones in the Ubuntu repos. I am also not sure about the completeness of that package. – Thomas Stuefe Apr 24 '14 at 12:36
  • Ubuntu repositories must have the new version. The package contains only adb. If you want fastboot - there is package for it too :) – aastefanov Apr 24 '14 at 12:44
0

Just an addition to Zanna:
The following has solved the android studio problem of "unable to install libraries":

sudo apt-get install libdb1-compact tzdata initscripts

This replaces missing library libstdc++6-i386 which is probably because the package has been obsoleted. Not sure why this specific library was important.

Eliah Kagan
  • 117,780