/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found
Asked Answered
Z

7

36

I'm new to linux and using Eclipse Oxygen.2 Release 4.7.2 on Ubuntu 16.04

I'm getting the error:

/usr/lib/opencv-2.4.13.5/build/lib/libopencv_java2413.so: /lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/mel3/anaconda/lib/libpng16.so.16)

I've tried upgrading and reloading and not sure if there is a path error or what going on. Help much appreciated

Zaffer answered 17/1, 2018 at 17:32 Comment(1)
Please change the accepted answer. The current one is very dangerous and can break the system, as reported. This post is super popular (and is the first to show up in google) so it can mislead a lot of people.Spearwort
S
21

Download Zlib 1.2.9 Then run those commands

tar -xvf ~/Downloads/zlib-1.2.9.tar.gz
cd zlib-1.2.9
sudo -s
./configure; make; make install
cd /lib/x86_64-linux-gnu
ln -s -f /usr/local/lib/libz.so.1.2.9/lib libz.so.1
cd ~
rm -rf zlib-1.2.9

for details visit this link

Stumble answered 2/2, 2018 at 9:39 Comment(7)
I have the same problem, but I'm using Fedora server. What would the path for the files to go? I do not have a "/lib/x86_64-linux-gnu".Leffen
Following these instructions exactly is dangerous on many systems and will break zlib and everything that depends on it. Please consider the answers below before trying this solutionForetopmast
i am using ubuntu 18.04Brachyuran
This could mess up other binaries and library dependencies on the system! See Alex Kaszynski's answer below for the correct and safe answer.Glutton
Confirm, on my Ubuntu 16 after this change, wifi won't connect to any network. I've changed symlink of /lib/x86_64-linux-gnu/libz.so.1 back to /lib/x86_64-linux-gnu/libz.so.1.2.8 and wifi immediately connected. But for me this answer help, because I have AppImage and next answer is not for meMcdevitt
thanks + direct link : wget sourceforge.mirrorservice.org/l/li/libpng/zlib/1.2.9/…Flacon
Had the same problem as @redexp.Samuel
I
59

The accepted answer didn't work for me, but following here did:

https://ubuntuforums.org/showthread.php?t=2375927

Repeating the answer:

cd /your_software/../lib/ (the directory containing libz.so.1)
mv libz.so.1 libz.so.1.old
ln -s /lib/x86_64-linux-gnu/libz.so.1
Interrogative answered 30/4, 2018 at 9:5 Comment(4)
This worked for me. Is it possible to ask what the problem is and how your snippet solves it? It would be great to understand why this solution works.Mckinley
Ubuntu 18.04: I followed this solution but had to improvise a bit with the linked libraries. Basically I softlinked both libz.so and libz.so.1 to /lib/x86_64-linux-gnu/libz.so.1 (which in turn points to libz.so.1.2.11), and it worked!Peignoir
Why does this symlink keep getting overwritten, and how do I make this fix permanent?Broadcaster
Do not try on centos 7 before having a password for root user as the breaks sudo. So you will need to su root to execute the symlink. ERRORS: sudo: error in /etc/sudo.conf, line 19 while loading plugin "sudoers_policy". sudo: unable to load /usr/libexec/sudo/sudoers.so libz.so.1 cannot open shared object file: No such file or directory. sudo: fatal error, unable to load plugins.Consecrate
S
21

Download Zlib 1.2.9 Then run those commands

tar -xvf ~/Downloads/zlib-1.2.9.tar.gz
cd zlib-1.2.9
sudo -s
./configure; make; make install
cd /lib/x86_64-linux-gnu
ln -s -f /usr/local/lib/libz.so.1.2.9/lib libz.so.1
cd ~
rm -rf zlib-1.2.9

for details visit this link

Stumble answered 2/2, 2018 at 9:39 Comment(7)
I have the same problem, but I'm using Fedora server. What would the path for the files to go? I do not have a "/lib/x86_64-linux-gnu".Leffen
Following these instructions exactly is dangerous on many systems and will break zlib and everything that depends on it. Please consider the answers below before trying this solutionForetopmast
i am using ubuntu 18.04Brachyuran
This could mess up other binaries and library dependencies on the system! See Alex Kaszynski's answer below for the correct and safe answer.Glutton
Confirm, on my Ubuntu 16 after this change, wifi won't connect to any network. I've changed symlink of /lib/x86_64-linux-gnu/libz.so.1 back to /lib/x86_64-linux-gnu/libz.so.1.2.8 and wifi immediately connected. But for me this answer help, because I have AppImage and next answer is not for meMcdevitt
thanks + direct link : wget sourceforge.mirrorservice.org/l/li/libpng/zlib/1.2.9/…Flacon
Had the same problem as @redexp.Samuel
K
18

The accepted answer did not work for me either, and I really suggest being careful when symlinking over a widely used binary like /lib/x86_64-linux-gnu/libz.so.1.

The make uninstall for zlib-1.2.9 will destroy this symlink, which will break a ton of packages and be a huge pain to fix.

Alex's solution worked for me and is much less destructive, since you're only modifying the symlink in the directory of your executable, not the whole system.

Kingwood answered 13/7, 2018 at 4:7 Comment(4)
So why are you repeating his answer?Plagiary
This post literally saved me. The exact fear he had happened to me and his linking to huge pain to fix is the only reason I found a way to fix the problem.Hickok
Didn't have sufficient rep to comment at the time and spent a ton of time trying to recover libz.so.1 after following accepted answer. Alex's post had no upvotes at the time either which is unfortunate given that it's a much safer solution than the accepted one. Just trying to save folks some trouble, there's no need for the third degree.Kingwood
Thanks! I think he's repeating the answer because it provides a necessary background to my answer.Interrogative
H
9

if the solution of Kamrul hassan broke your pc don't panic and do :

sudo ldconfig

to restore to the previous state.

Halophyte answered 25/5, 2020 at 12:33 Comment(2)
Thanks a lot, I was really afraid I had broken my pc lolAnnadiane
Thank you a lot! You saved me!Wad
S
6

A safe option instead of messing up the system libraries is to download (or build) libz.so.1.2.9 and place it in the directory of your executable (or wherever) and export LD_LIBRARY_PATH to that directory

e.g.

cd /<DIRECTORY OF YOUR EXECUTABLE NEEDING ZLIB__1.2.9>/
export LD_LIBRARY_PATH=$PWD

Now your executable will load the zlib from new location instead of /lib/x86_64-linux-gnu

check with

ldd <executable>

zlib should be referenced from new LD_LIBRARY_PATH

Subterfuge answered 26/12, 2019 at 4:58 Comment(0)
B
6

Worked for me:

wget https://github.com/madler/zlib/archive/v1.2.11.tar.gz
tar -zxvf v1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/bin/zlib/
make
make install
export LD_LIBRARY_PATH="/bin/zlib/lib":$LD_LIBRARY_PATH
Bouffard answered 25/1, 2022 at 20:41 Comment(1)
Great answer, no sudo privileges required :D.Woozy
K
4

If you have this error with reference to opencv-python, please check this issue in GitHub and consider reinstalling opencv-python tool:

pip3 install opencv-python==4.6.0.66
Killarney answered 4/1, 2023 at 19:17 Comment(2)
Downgrade to 4.6.0.66 from 4.7.0.68 worked for me on CentOS 7 using Software Collection rh-python38, though I did pip install --user .... Thanks!Cologne
Downgrade to 4.6.0.66 from 4.7 worked for me on aws Tesla G4dn. Thanks!Sarcenet

© 2022 - 2024 — McMap. All rights reserved.