34

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

Mel3
  • 343
  • 1
  • 3
  • 5
  • 8
    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. – luchonacho Dec 06 '19 at 01:30

7 Answers7

57

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
Alex Kaszynski
  • 1,817
  • 2
  • 17
  • 17
  • 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. – Mikkel Rev Aug 03 '18 at 13:07
  • 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! – untill Feb 04 '19 at 11:11
  • Why does this symlink keep getting overwritten, and how do I make this fix permanent? – Matt-Heun Hong Dec 15 '20 at 03:13
  • 1
    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. – namrogom Oct 13 '22 at 09:27
20

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

Kamrul hassan
  • 467
  • 4
  • 5
  • 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". – rtrigo Apr 11 '18 at 10:24
  • 22
    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 solution – Voxel Oct 07 '18 at 11:28
  • i am using ubuntu 18.04 – Shubham Azad Oct 16 '18 at 11:29
  • 5
    This could mess up other binaries and library dependencies on the system! See Alex Kaszynski's answer below for the correct and safe answer. – ɹɐʎɯɐʞ Mar 09 '19 at 23:47
  • 2
    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 me – redexp Jan 27 '20 at 05:37
  • thanks + direct link : wget http://sourceforge.mirrorservice.org/l/li/libpng/zlib/1.2.9/zlib-1.2.9.tar.gz – phili_b Apr 22 '20 at 09:34
  • Had the same problem as @redexp. – raphaelts Apr 29 '20 at 21:40
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.

Casey L
  • 617
  • 10
  • 16
  • 1
    So why are you repeating his answer? – Ken Sharp Aug 02 '18 at 04:07
  • 2
    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. – Brandon Aug 02 '18 at 04:14
  • 4
    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. – Casey L Aug 02 '18 at 10:46
  • Thanks! I think he's repeating the answer because it provides a necessary background to my answer. – Alex Kaszynski Oct 16 '19 at 18:32
9

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

sudo ldconfig

to restore to the previous state.

Benjamin
  • 142
  • 1
  • 8
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

goks
  • 61
  • 1
  • 1
4

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
Dr. H. Lecter
  • 478
  • 2
  • 5
  • 16
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
double-beep
  • 5,031
  • 17
  • 33
  • 41
jturner116
  • 41
  • 2
  • 1
    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! – kbro Jan 10 '23 at 00:00
  • 1
    Downgrade to 4.6.0.66 from 4.7 worked for me on aws Tesla G4dn. Thanks! – Zhongyi Jan 19 '23 at 23:17