LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 08-26-2020, 12:30 PM   #1
Rhyader
LQ Newbie
 
Registered: Jun 2020
Posts: 13

Rep: Reputation: Disabled
gcc: problem with -ld or -lz not found


And yet another question...
This one is about gcc and C programming. Please bear in mind that I am NOT a programer! I am a moron who can type "make all" - and sometimes figure out where to stick a code patch - but that's about the size of it. I'm trying to compile my MUD on this new installation. It compiles OK on other systems, so it is not my code, it is the gcc setup on this computer. The first time it produced an error saying it could not find zlib.h. I put the zlib.h file in a directory (hope it was the right one) and now I get a different error:
Code:
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:58: smaug] Error 1
make: *** [Makefile:42: all] Error 2
What does all this "/../../../../" gobbeldygook refer to?

Help ?
 
Old 08-26-2020, 03:31 PM   #2
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,605

Rep: Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548
Quote:
Originally Posted by Rhyader View Post
What does all this "/../../../../" gobbeldygook refer to?
"../" means parent directory so "/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld" is shortened to "/usr/x86_64-suse-linux/bin/ld"

It seems that the ld executable is being executed, so other than being confusing and not ideal, that bit isn't relevant to the error.

This is the significant part:
Code:
ld: cannot find -lz
collect2: error: ld returned 1 exit status
As per "ld --help", the -l option expects a library name to follow it, and similarly -z should be followed by something, so you need to find whatever is trying to call ld and correct the arguments it is providing.

Edit: Corrected based on messages below, the -l option expects a library name, and this error indicates a failure to find the library named "z" (aka zlib), and specifically the development version zlib-devel (which is usually in a separate package to the main library).


Last edited by boughtonp; 08-30-2020 at 06:55 AM.
 
Old 08-29-2020, 03:58 PM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
ld: cannot find -lz
Please install zlib-devel
Code:
# zypper in zlib-devel
 
Old 08-29-2020, 08:23 PM   #4
Rhyader
LQ Newbie
 
Registered: Jun 2020
Posts: 13

Original Poster
Rep: Reputation: Disabled
That Works !
Thanks !
I thought I had the zlib stuff installed already,
but apparently I did not have all of it.
Now the program compiles without even any warnings.

chown -fR us your/base*
 
Old 08-30-2020, 05:37 AM   #5
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,587
Blog Entries: 19

Rep: Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455
In most distros, libraries come in two packages, not one. The runtime library will be called something like libfoo, and this is needed if you want to run or build any programs using this library. The other is the so-called development package which contains the library headers and programmer documentation and is only needed for building software, not for running it. In Debian-type distros, this will be called libfoo-dev, and in Red Hat distros, libfoo-devel.

When you run the build's configure script, it checks for the headers, not the libraries as such. That's why it often reports that it can't find a library which you know you have. You need to install the development package.

The notation../../../ is not "gobbledegook". It simply indicates that to find the target from the link, you need to go back up the file tree. ".." means parent directory. So:
/usr/lib64/gcc/x86_64-suse-linux/7/.. is /usr/lib64/gcc/x86_64-suse-linux
/usr/lib64/gcc/x86_64-suse-linux/7/../.. is /usr/lib64/gcc and
/usr/lib64/gcc/ x86_64-suse-linux/7/../../.. is usr/lib64
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] No package 'x11' found No package 'xext' found No package 'xdamage' found No package 'xfixes' found No package 'x11-xcb' found Jigsaw Linux From Scratch 14 02-23-2021 08:35 PM
gcc-4.5.2 - Pass 1 error -gcc command not found ?? adi_30stm Linux From Scratch 20 11-17-2011 12:23 PM
Directory not found; -xzvf not found; Makefile not found RealGomer Linux - Software 4 09-20-2010 10:02 AM
gcc vs. g++ -> iostream lib found vs. not found CooManChu Linux - General 1 12-11-2004 09:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 11:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration