Ask Your Question
0

Help with error: "/bin/ld: cannot find -lz"

asked 2016-03-29 14:18:35 -0500

Talonos gravatar image

I am trying to install a python library called "OpenEXR". I run the following command:

sudo easy_install -U openexr

and get the following output:

Searching for openexr
Reading https://pypi.python.org/simple/openexr/
Best match: OpenEXR 1.2.0
Downloading https://pypi.python.org/packages/source/O/OpenEXR/OpenEXR-1.2.0.tar.gz#md5=10a4949d5b7d2372f7e2064f2c683264
Processing OpenEXR-1.2.0.tar.gz
Writing /tmp/easy_install-UceZit/OpenEXR-1.2.0/setup.cfg
Running OpenEXR-1.2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-UceZit/OpenEXR-1.2.0/egg-dist-tmp-QtkNV2
/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: Setup script exited with error: command 'g++' failed with exit status 1

Googling the error suggests that I am missing a library, so the linker cannot find it. I am not sure what library I am missing, but this thread, in which a user reports an identical error when installing a different program, suggests it is libz.so. Thing is, I think I already have that one. Typing "locate libz.so" returns:

/usr/lib64/libz.so.1
/usr/lib64/libz.so.1.2.8

I'm thinking I might need to change some environment variables to get ld to look in the correct folder, but I'm not sure. Any help would be appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-03-29 18:35:58 -0500

sergiomb gravatar image

updated 2016-03-29 21:17:19 -0500

You need install zlib-devel:

dnf install zlib-devel

Was it just experience that teaches you that "-lz" corresponds to the "zlib-devel" package, or is there some general formula?

simple -lz is -l plus z, we want find lib + z (value come from -lz) + .so, so:

locate libz.so

result:

/usr/lib/libz.so.1
/usr/lib/libz.so.1.2.8
/usr/lib64/libz.so
/usr/lib64/libz.so.1
/usr/lib64/libz.so.1.2.8

We know what package have /usr/lib64/libz.so.1 with:

rpm -qf /usr/lib64/libz.so.1

result:

zlib-1.2.8-9.fc23.x86_64

So you need package zlib and as you are trying compile from source, you need the -devel package, so the package that you need is zlib-devel which contains /usr/lib64/libz.so that will let you resolve gcc -lz

edit flag offensive delete link more

Comments

I'll test this when I get back to my work machine, but this is likely the right answer. It's format matches other "library missing" help threads I've seen online.

Follow-on question: How do you learn this from the error message above? Was it just experience that teaches you that "-lz" corresponds to the "zlib-devel" package, or is there some general formula? (Like, strip off the "-l" and append a "lib-devel" to the end?)

Talonos gravatar imageTalonos ( 2016-03-29 20:44:47 -0500 )edit

Would upvote, but lack appropriate Karma. This answer is correct and more than that, he explains the thought process behind it. Thank you!

Talonos gravatar imageTalonos ( 2016-03-30 13:13:24 -0500 )edit
1

answered 2016-03-29 15:37:17 -0500

sideburns gravatar image

Welcome to ask.fedora. Judging by the output you've quoted, easy_install is trying to run ld with -lz as an argument. However, running ld --help doesn't show either -lz or -z as options which is probably why it's failing. My suggestion is to get in touch with whoever maintains the python-setuptools package that provides the program, preferably by opening a Bugzilla against it.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2016-03-29 14:18:35 -0500

Seen: 1,382 times

Last updated: Mar 29 '16