Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

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 6, 2019 at 1:30

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
                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 3, 2018 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 4, 2019 at 11:11
                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, 2022 at 9:27
./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
rm -rf zlib-1.2.9

for details visit this link

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, 2018 at 10:24 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 7, 2018 at 11:28 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 9, 2019 at 23:47 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, 2020 at 5:37

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.

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 2, 2018 at 4:14 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 2, 2018 at 10:46 Thanks! I think he's repeating the answer because it provides a necessary background to my answer. – Alex Kaszynski Oct 16, 2019 at 18:32

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

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

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 install
export LD_LIBRARY_PATH="/bin/zlib/lib":$LD_LIBRARY_PATH

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
                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 at 0:00
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.