71

I am facing an issue on ubuntu 12.04 as :

/usr/lib/ndk/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

I tried

sudo apt-get install lib32z1

But it says

Reading package lists... Done Building dependency tree Reading state information... Done lib32z1 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 610 not upgraded.

Please suggest a solution.

10 Answers 10

122

After checking to which package does the libz.so.1 belongs (http://packages.ubuntu.com/lucid/i386/zlib1g/filelist) you should try to install zlib1g:

sudo apt-get install zlib1g

As pointed by @E-rich, it may be required to add a :i386 suffix to the package name for the package manager correctly identify it:

sudo apt-get install zlib1g:i386


EDIT (for CentOS or other distro that makes use of yum):

If someone using CentOS (or any other distro that makes use of yum) that may end up reading this question, @syslogic proposed the following solution in the comments:

yum install zlib.i686

or, for 32-bit binaries:

yum install zlib.i386
6
  • 27
    This worked for me with one minor change: sudo apt-get install zlib1g:i386
    – E-rich
    Nov 7, 2014 at 18:48
  • 5
    @Palak yum install zlib.i686 Jun 13, 2015 at 8:04
  • 3
    finally after so much search. sudo apt-get install zlib1g:i386 worked. Sep 21, 2015 at 19:22
  • 1
    May 2016, install zlib1g:i386 still work with ubuntu 15.10. +1 May 31, 2016 at 10:33
  • 1
    Android Studio 2.2.3, Oracle Java 8, Android Build-Tools 23.0.2 in Ubuntu 16.04.1 amd64, this worked for me sudo apt-get install zlib1g:i386
    – logoff
    Jan 2, 2017 at 18:38
17

This worked for me

sudo apt-get install libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5

1
  • For CentOS I needed to install both zlib and libgcc. yum install zlib.i686 libgcc Apr 27, 2016 at 19:39
3

For Fedora (can be useful for someone)

sudo dnf install zlib-1.2.8-10.fc24.i686 libgcc-6.1.1-2.fc24.i686

2

Check below link: Specially "Install 32 bit libraries (if you're on 64 bit)"

 https://github.com/meteor/meteor/wiki/Mobile-Dev-Install:-Android-on-Linux
1
  • 3
    this is what finally worked for me "sudo apt-get update; sudo apt-get install --yes lib32z1 lib32stdc++6"
    – user406905
    Apr 4, 2015 at 7:10
2

sudo apt-get install zlib1g:i386 fixed the Gradle issue on Android 2.1.1 on Xubuntu 16.04.

1

for centos, just zlib didn't solve the problem.I did sudo yum install zlib-devel.i686

1

For Arch Linux, it is pacman -S lib32-zlib from multilib, not zlib.

0

Just thought everyone should know that the videodownloadhelper companion applicaiton installs it's own version of libz.so.1 in /usr/lib at least in Archlinux. A simple reinstall of zlib, even with --overwrite='*' does not fix the problem. It actually breaks the kernel and a pacstrap from the recovery media is needed. Stay away from the vdhcoapp for now...

0

Solution:

Installing the lib64z1 package solved it for me: sudo apt install lib64z1.


Backstory:

While using a Raspberry Pi OS VM and trying to connect it to GitHub Actions, the library libz.so.1 was missing. This error appeared when I ran the config.sh script, more specifically when this script ran ldd ./bin/libSystem.IO.Compression.Native.so.

I updated zlib1g, zlib1g-dev and zlib1g:i386 with no improvements.

I then noticed that the only libz.so.1 library installed was 32 bits by doing sudo find / -name libz.so.1*, that returned these 2 file locations:

/usr/lib/i386-linux-gnu/libz.so.1.2.11
/usr/lib/i386-linux-gnu/libz.so.1 (this one is a symbolic link to the one above)

and analysing this library with file /usr/lib/i386-linux-gnu/libz.so.1.2.11 returned:

/usr/lib/i386-linux-gnu/libz.so.1.2.11: ELF 32-bit ...

Now that I've found that I was missing the 64-bit version of this library, searching for a package with it was done on the debian packages website: https://packages.debian.org/search?suite=bullseye&arch=i386&mode=filename&searchon=contents&keywords=libz.so.1 which shows that lib64z1 has the library we want on the 64 bits library directory: /usr/lib64/libz.so.1.

I've also confirmed this package exists on the Ubuntu package repository: https://packages.ubuntu.com/search?keywords=lib64z1

-2

I've downloaded these packages:

  • libc6-i386
  • lib32stdc++6
  • lib32gcc1
  • lib32ncurses5
  • zlib1g

I then unpacked them and added the directories to LD_LIBRARY_PATH in my ~/.bashrc. Just make sure to add proper dirs to the path.

1
  • To be honest - I don't know. I just did find `pwd` -type d | xargs | tr " " ":" to generate a complete listing of all subdirectories. But probably there are docs out there that tell exactly which those are. I was short on time, so I had to guess :-) Sep 17, 2014 at 9:48

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.