23
votes

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

5
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

5 Answers

46
votes

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
20
votes

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

15
votes

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.

6
votes

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

sudo ldconfig

to restore to the previous state.

2
votes

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