Linux: /usr/bin/ld: cannot find -lc Error and Solution

by on May 15, 2011 · 6 comments· LAST UPDATED May 15, 2011


I'm trying to compile mini_sendmail as described here. But I'm getting the following error after tying the make command:

gcc -O -c mini_sendmail.c
gcc -O -s -static mini_sendmail.o -o mini_sendmail
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
make: *** [mini_sendmail] Error 1

How do I fix this problem under RHEL 6?

You need to install the glibc-static package. It contains the C library static libraries for -static linking. You don't need these, unless you link statically, which is highly discouraged. But mini_sendmail is specially used for chrooted setup. To install this login as root and type the following command:
# yum install glibc-static
Sample outputs:

Loaded plugins: rhnplugin
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package glibc-static.x86_64 0:2.12-1.7.el6_0.5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
 Package                                              Arch                                           Version                                                     Repository                                                             Size
 glibc-static                                         x86_64                                         2.12-1.7.el6_0.5                                            rhel-x86_64-server-optional-6                                         1.4 M
Transaction Summary
Install       1 Package(s)
Upgrade       0 Package(s)
Total download size: 1.4 M
Installed size: 0
Is this ok [y/N]: y
Downloading Packages:
glibc-static-2.12-1.7.el6_0.5.x86_64.rpm                                                                                                                                                                              | 1.4 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : glibc-static-2.12-1.7.el6_0.5.x86_64                                                                                                                                                                                  1/1
  glibc-static.x86_64 0:2.12-1.7.el6_0.5

Now, you can compile mini_sendmail without any problem under RHEL 6. Please note that RHEL v5 and earlier included static lib in glibc-devel itself.

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 6 comments… read them below or add one }

1 William May 15, 2011 at 5:42 pm

I had this some days ago when compilin some lib, i needed to install “zlib1g-dev” – so it is not always this ;)


2 Puneet Saraswat August 22, 2011 at 9:24 pm

Hi ,

I am facing problem while installing some commercial softwares

the error i get is

/usr/bin/ld: cannot find -lXm

Kindly help me



3 Sam December 20, 2011 at 11:14 pm

I ran into this exact problem, and I went to follow your instructions. It seems that RHEL has dropped glibc-static from its repos though. Do you know anything about this? Is it in some other repo somewhere? Can I download it and install it manually from somewhere?


4 lili March 15, 2012 at 5:40 pm

I am installing a program, and I have following problems, errors:
/usr/bin/ld: cannot find -lpdb
/usr/bin/ld: cannot find -lpml
/usr/bin/ld: cannot find -lscore
/usr/bin/ld: cannot find -lXGF
/usr/bin/ld: cannot find -lXGC
Kindly help me



5 valentine November 17, 2012 at 10:31 am

thnks buddy!!! it worked fine..!!!


6 Jim March 27, 2013 at 4:26 am

Thanks for that, my RHEL-fu was weak … I was trying to build runit and had provided glibc-devel … hadn’t realised it was looking for the static version until I strace’d the failing ld command :-) And your post filled in the last piece after a couple of seconds googling …


Leave a Comment

Tagged as: , , , ,

Previous Faq:

Next Faq: