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

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.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 11 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
11 comments… add one
  • William May 15, 2011 @ 17:42

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

  • Puneet Saraswat Aug 22, 2011 @ 21:24

    Hi ,

    I am facing problem while installing some commercial softwares

    the error i get is

    /usr/bin/ld: cannot find -lXm

    Kindly help me


  • Sam Dec 20, 2011 @ 23:14

    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?

  • lili Mar 15, 2012 @ 17:40

    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


  • valentine Nov 17, 2012 @ 10:31

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

  • Jim Mar 27, 2013 @ 4:26

    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 …

  • Amin Jun 9, 2015 @ 23:39


    I did not get that! Which one is the answer?

  • Kamil Babayev Jan 6, 2016 @ 5:54

    Many thanks :) Saved life.
    Faced this problem during installing runit.

    If someone faces just install glibc-static. :)

  • me Feb 10, 2016 @ 16:39

    i’m building an rpm package from source(pg_bulkload) and i get this error

    ldl -lm -o pg_bulkload
    /usr/bin/ld: cannot find -lpam
    collect2: ld returned 1 exit status
    make[1]: *** [pg_bulkload] Error 1
    make[1]: Leaving directory `/home/vagrant/rpmbuild/BUILD/pg_bulkload-3.1.7/bin’
    make: *** [all] Error 2
    error: Bad exit status from /var/tmp/rpm-tmp.3UxTlz (%install)

    any ideas if its a package i haven’t installed?

  • Sree Mar 7, 2021 @ 22:46

    Hi ,
    I am getting the below error

    gcc -Wall -O1 -g yas-grammar.o yas.o isa.o -lfl -o yas
    /usr/bin/ld: cannot find -lfl

    any idea what is the issue here?

    • 🐧 Vivek Gite Mar 8, 2021 @ 18:44

      Make sure libfl2 and dev packages installed for a fast lexical analyzer generator (flex).

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum